public void GenereteLessonDeatail(Schedule addedSchedule)
        {
            bool IsLessonDateInHolidays = false;
            var holidays = this.unitOfWork.HolidaysRepository.GetAll();
            var IsExistLessonDetalis = this.unitOfWork.LessonDetailRepository.GetMany(p => p.ScheduleId == addedSchedule.Id);
            DateTime DataOfLesson;
            DateTime StartTerm = new DateTime(2015, 09, 1);
            DateTime EndTerm = new DateTime(2015, 12, 30);
            DateTime FirstDateOfLesson = StartTerm;
            LessonDetail NewLessonDetail;
                do
                {
                    if ((int)StartTerm.DayOfWeek == addedSchedule.DayOfTheWeek)
                    {
                        FirstDateOfLesson = StartTerm;
                        break;
                    }
                    else
                    {
                        StartTerm = StartTerm.AddDays(1);
                    }
                } while (StartTerm < EndTerm);

            if (IsExistLessonDetalis.Count() == 0)
            {
                DataOfLesson = FirstDateOfLesson;
                do
                {
                    IsLessonDateInHolidays = false;

                    foreach (var holiday in holidays)
                    {
                        if (holiday.Name.Contains("Semestr") == false)
                        {
                            if (DataOfLesson > holiday.StartDay && DataOfLesson < holiday.EndDay)
                            {
                                IsLessonDateInHolidays = true;
                                break;
                            }
                        }
                    }
                    if (!IsLessonDateInHolidays)
                    {
                        NewLessonDetail = new LessonDetail { ScheduleId = addedSchedule.Id, Date = DataOfLesson, SchoolId = 1 };
                        this.unitOfWork.LessonDetailRepository.Add(NewLessonDetail);
                        this.SaveLessonDetail();
                    }
                    DataOfLesson = DataOfLesson.AddDays(7);
                } while (DataOfLesson <= EndTerm);
            }
            else
            {
                foreach (var lessonDetail in IsExistLessonDetalis)
                {
                    lessonDetail.ScheduleId = addedSchedule.Id;
                    UpdateLessonDetail(lessonDetail);
                    this.SaveLessonDetail();
                }

            }
        }
 public void UpdateLessonDetail(LessonDetail value)
 {
     this.unitOfWork.LessonDetailRepository.Update(value);
     this.SaveLessonDetail();
 }