public ActionResult Insert() { var labours = labourRepository.GetAll().OrderBy(l => l.Name); var services = serviceRepository.GetAll().OrderBy(s => s.ServiceName); var viewModel = new LabourServiceMapFormViewModel { Labours = labours, Services = services }; return(View(viewModel)); }
public ActionResult CreateOrUpdate(LabourServiceMapFormViewModel viewModel) // model binding { if (viewModel.LabourServiceMap.Id == 0) // Create { labourServiceMapRepository.Insert(viewModel.LabourServiceMap); return(RedirectToAction("LabourServiceMapList", "LabourServiceMap")); } else // Update { var labourServiceMap = labourServiceMapRepository.Update(viewModel.LabourServiceMap); return(RedirectToAction("LabourServiceMapList", "LabourServiceMap")); } }
public ActionResult Edit(int id) { var labourServiceMap = labourServiceMapRepository.Get(id); var labours = labourRepository.GetAll().OrderBy(l => l.Name); var services = serviceRepository.GetAll().OrderBy(s => s.ServiceName); if (labourServiceMap == null) { return(HttpNotFound()); } var viewModel = new LabourServiceMapFormViewModel { LabourServiceMap = labourServiceMap, Labours = labours, Services = services }; return(View(viewModel)); }