Exemple #1
0
        public bool CreateCourse(Course course, string userId)
        {
            try
            {
                if (course.From >= course.To)
                {
                    return(false);
                }

                course.Name        = course.Name.Trim();
                course.UserCreated = userId;
                foreach (var i in course.Instructors)
                {
                    var instructor = Instructors.FindById(i.InstructorId);
                    if (!instructor.IsAvailable(course.From, course.To))
                    {
                        return(false);
                    }

                    if (!instructor.Rentals.Any(x => x.RentalId == course.RentalId))
                    {
                        return(false);
                    }

                    if (!instructor.HasExpertise(Expertises.FindById(course.ExpertiseId), ExpertiseLevels.FindById(course.ExpertiseLevelId)))
                    {
                        return(false);
                    }


                    if (course.LanguageId.HasValue && !instructor.HasLanguage(Languages.FindById(course.LanguageId.Value),
                                                                              course.LanguageLevelId.HasValue? LanguageLevels.FindById(course.LanguageLevelId.Value) : null))
                    {
                        return(false);
                    }
                }

                Courses.Add(course);
                return(true);
            }
            catch (Exception e)
            {
            }
            return(false);
        }
Exemple #2
0
 public bool CreateInstructorAvailability(InstructorAvailability availability, string userId)
 {
     try
     {
         var instructor = Instructors.FindById(availability.InstructorId);
         if (availability.From < availability.To)
         {
             availability.UserCreated = userId;
             instructor.Availabilities.Add(availability);
         }
         Instructors.Update(instructor);
         return(true);
     }
     catch (Exception e)
     {
     }
     return(false);
 }
Exemple #3
0
 public bool CreateInstructorAvailability(ICollection <InstructorAvailability> availabilities, string userId)
 {
     try
     {
         if (availabilities.Any())
         {
             var instructor = Instructors.FindById(availabilities.FirstOrDefault().InstructorId);
             foreach (var availability in availabilities)
             {
                 if (availability.From < availability.To)
                 {
                     availability.UserCreated = userId;
                     instructor.Availabilities.Add(availability);
                 }
             }
             Instructors.Update(instructor);
             return(true);
         }
     }
     catch (Exception e)
     {
     }
     return(false);
 }