Techworld is a technology training center, providing training to their clients on various technologies.They need to automate the process of allocating instructiors for different courses.An instructor is identified by his/her name and may be skilled in multiple technologies .Assume that the skills of an instructor are stored in an array.
public void SetInstructor(Course course)
{
var courses = GetCourses();
var availableInstructors = GetAvailableInstructors(course.Technology, courses, course.StartDate);
if (availableInstructors.Count() > 0)
{
course.Instructor = availableInstructors.First();
}
}
public IEnumerable<Instructor> GetAvailableInstructors(Technology technology, List<Course> courses, DateTime startDate)
{
var instructors = GetInstructors();
return instructors.Where(i =>
{
if (i.Technologies.All(t => t != technology))
{
return false;
}
if (courses.Any(c => DateTime.Compare(c.EndDate, startDate) >= 0 && c.Instructor.FullName.Equals(i.FullName)))
{
return false;
}
return true;
});
}
Comments
Leave a comment