public ActionResult Delete(int?serviceTypePK) { IServiceTypesRepository serviceTypesRepository = new ServiceTypesRepository(db); if (serviceTypePK != null) { ServiceType serviceType = serviceTypesRepository.GetServiceTypeByPK((int)serviceTypePK); serviceType.Deleted = true; serviceTypesRepository.SaveChanges(); TempData["message"] = LayoutHelper.GetMessage("DELETE", serviceType.ServiceTypePK); } return(Redirect(Request.UrlReferrer.AbsoluteUri)); }
public ActionResult Edit(int?serviceTypePK) { if (serviceTypePK != null) { IServiceTypesRepository serviceTypesRepository = new ServiceTypesRepository(db); ServiceType serviceType = serviceTypesRepository.GetServiceTypeByPK((int)serviceTypePK); ServiceTypeView serviceTypeView = new ServiceTypeView(); serviceTypeView.ConvertFrom(serviceType, serviceTypeView); return(View(serviceTypeView)); } else { return(RedirectToAction("Index", "ServiceType")); } }
public ActionResult Edit(ServiceTypeView serviceTypeModel) { if (ModelState.IsValid) { IServiceTypesRepository serviceTypesRepository = new ServiceTypesRepository(db); ServiceType serviceType = serviceTypesRepository.GetServiceTypeByPK((int)serviceTypeModel.ServiceTypePK); serviceTypeModel.ConvertTo(serviceTypeModel, serviceType); serviceTypesRepository.SaveChanges(); TempData["message"] = LayoutHelper.GetMessage("UPDATE", serviceType.ServiceTypePK); return(RedirectToAction("Index", "ServiceType")); } else { return(View(serviceTypeModel)); } }