Answer to Question #329780 in C# for Durga

Question #329780

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.



1
Expert's answer
2022-04-17T11:03:41-0400
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;
   });
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS