public ActionResult EditWeekly(long id = 0) { var viewModel = new ScheduleEditData <WeeklySchedule>(); viewModel.Tools = unitOfWork.ToolRepository.GetAll(); viewModel.Contacts = unitOfWork.GetMiscRepository <Contact>().GetAll(); Schedule thisschedule = unitOfWork.ScheduleRepository.Get( filter: f => f.Id == id, includeProperties: "Tool,Contact,Devices") .Single(); viewModel.Schedule = (WeeklySchedule)thisschedule; if (viewModel == null) { return(HttpNotFound()); } return(View(viewModel)); }
// // GET: /Schedule/Edit/5 public ActionResult Edit(long id = 0) { Schedule schedule = unitOfWork.ScheduleRepository.GetByID(id); if (schedule == null) { return(HttpNotFound()); } if (schedule is DailySchedule) { return(RedirectToAction("EditDaily", new { id = schedule.Id })); } else if (schedule is WeeklySchedule) { return(RedirectToAction("EditWeekly", new { id = schedule.Id })); } else if (schedule is MonthlySchedule) { return(RedirectToAction("EditMonthly", new { id = schedule.Id })); } else { var viewModel = new ScheduleEditData <Schedule>(); viewModel.Tools = unitOfWork.ToolRepository.GetAll(); viewModel.Contacts = unitOfWork.GetMiscRepository <Contact>().GetAll(); viewModel.Devices = unitOfWork.DeviceRepository.GetAll(); Schedule thisschedule = unitOfWork.ScheduleRepository.Get( filter: f => f.Id == id, includeProperties: "Tool,Contact,Devices") .Single(); viewModel.Schedule = thisschedule; if (viewModel == null) { return(HttpNotFound()); } return(View(viewModel)); } }