public ActionResult AddLesson(ScheduleItem schedule)
        {
            try
            {
                // TODO: Add insert logic here
                ApplicationDbContext context = new ApplicationDbContext();
                if (ModelState.IsValid)
                {
                    context.ScheduleItems.Add(schedule);
                }
                context.SaveChanges();

                int course = context.Groups.Single(i => i.Id == schedule.GroupId).Course;

                return RedirectToAction("View", new { course = course });
            }
            catch (Exception ex)
            {
                return View();
            }
        }
        public PartialViewResult _LessonForm(int semesterId, string dayOfWeek, int lessonNumber, int groupId, LessonFrequency lessonFrequency = LessonFrequency.Constant)
        {
            ApplicationDbContext context = new ApplicationDbContext();

            Models.ScheduleItem scheduleItem = new ScheduleItem()
            {
                SemesterId = semesterId,
                DayOfWeek = dayOfWeek,
                LessonNumber = lessonNumber,
                GroupId = groupId,
                LessonFrequency = lessonFrequency
            };
            scheduleItem.Group = context.Groups.Single(i => i.Id == groupId);

            //Отбираем значения числ/знам по загруж
            ScheduleViewModel vm = ScheduleRepository.GetScheduleViewModel(semesterId, scheduleItem.Group.Course);

            IEnumerable<SelectListItem> freqList =  GetLessonFrequenciesSelectList();

            Hashtable freqLimitReached = new Hashtable();

            foreach (var value in EnumHelper.GetValues<LessonFrequency>())
            {
                freqLimitReached.Add(value.ToString(), vm.StudLessonsLimitReached(dayOfWeek, groupId, value));
            }
            freqList = freqList.Where(i => (bool)freqLimitReached[i.Value] == false );

            //проверка на другие занятия
            List<SelectListItem> freqList2 = new List<SelectListItem>();
            var scheduleItemsForConcreteLessonNumber = vm.GetScheduleItems(semesterId, dayOfWeek, lessonNumber, groupId).Select(i => i.LessonFrequency);
            if (scheduleItemsForConcreteLessonNumber.Contains(LessonFrequency.Constant))
            {
                freqList2.Clear();
            }
            else if (scheduleItemsForConcreteLessonNumber.Contains(LessonFrequency.Nominator))
            {
                freqList2.Add(freqList.SingleOrDefault(i => i.Value == LessonFrequency.Denominator.ToString()));
            }
            else if (scheduleItemsForConcreteLessonNumber.Contains(LessonFrequency.Denominator))
            {
                freqList2.Add(freqList.SingleOrDefault(i => i.Value == LessonFrequency.Nominator.ToString()));
            }
            else
            {
                freqList2.AddRange(freqList);
            }
            freqList = freqList2;

            ViewBag.LessonId = GetLessonsSelectList();
            ViewBag.LessonType = GetLessonTypesSelectList();
            ViewBag.LessonFrequency = freqList;
            ViewBag.TeacherId = GetTeachersSelectList();
            ViewBag.ClassroomId = GetClassroomsSelectList(context.Classrooms.Where(i => i.Capacity >= scheduleItem.Group.StudentsAmount).ToList());

            return PartialView("_LessonFormPartial", scheduleItem);
        }