public ActionResult AddItem(Guid? scheduleId, int dayNumber, int subgroupNumber, int order, Guid groupId)
        {
            var repositories = new RepositoryFactory();
            var scheduleManager = new ScheduleManager(repositories);
            if (scheduleId == null)
            {
                var schedule = new DBLE.Schedule
                    {
                        Id = Guid.NewGuid(),
                        Items = new List<DBLE.Item>()
                    };
                scheduleManager.AddGroupSchedule(groupId, schedule, subgroupNumber);
                repositories.Commit();

                return View(new Item
                {
                    Id = Guid.NewGuid(),
                    ScheduleId = (Guid)schedule.Id,
                    DataId = groupId,
                    Order = order,
                    NumberOfDay = dayNumber
                });
            }

            return View(new Item
                {
                    Id = Guid.NewGuid(),
                    ScheduleId = (Guid)scheduleId,
                    DataId = groupId,
                    Order = order,
                    NumberOfDay = dayNumber

                });
        }
 public void AddGroupSchedule(Guid groupId, Schedule schedule, int subGroupNumber)
 {
     switch (subGroupNumber)
     {
         case 1: { r.GroupRepository.GetById(groupId).Schedule1 = schedule; break;}
         case 2: { r.GroupRepository.GetById(groupId).Schedule2 = schedule; break;}
         default:
             {
                 throw new InvalidOperationException("Subgroup number mast be 1 or 2");
             }
     }
 }
 public void AddTeacherSchedule(Schedule schedule, Guid teacherId)
 {
     r.TeacherRepository.GetById(teacherId).Schedule = schedule;
     r.ScheduleRepository.Insert(schedule);
 }