public ActionResult Delete(int?regionalOfficePK) { IRegionalOfficesRepository regionalOfficesRepository = new RegionalOfficesRepository(db); if (regionalOfficePK != null) { RegionalOffice regionalOffice = regionalOfficesRepository.GetRegionalOfficeByPK((int)regionalOfficePK); regionalOffice.Deleted = true; regionalOfficesRepository.SaveChanges(); TempData["message"] = LayoutHelper.GetMessage("DELETE", regionalOffice.RegionalOfficePK); } return(Redirect(Request.UrlReferrer.AbsoluteUri)); }
public ActionResult Edit(int?regionalOfficePK) { if (regionalOfficePK != null) { IRegionalOfficesRepository regionalOfficesRepository = new RegionalOfficesRepository(db); RegionalOffice regionalOffice = regionalOfficesRepository.GetRegionalOfficeByPK((int)regionalOfficePK); RegionalOfficeView regionalOfficeView = new RegionalOfficeView(); regionalOfficeView.ConvertFrom(regionalOffice, regionalOfficeView); return(View(regionalOfficeView)); } else { return(RedirectToAction("Index", "RegionalOffice")); } }
public ActionResult Edit(RegionalOfficeView regionalOfficeModel) { if (ModelState.IsValid) { IRegionalOfficesRepository regionalOfficesRepository = new RegionalOfficesRepository(db); RegionalOffice regionalOffice = regionalOfficesRepository.GetRegionalOfficeByPK((int)regionalOfficeModel.RegionalOfficePK); regionalOfficeModel.ConvertTo(regionalOfficeModel, regionalOffice); regionalOfficesRepository.SaveChanges(); TempData["message"] = LayoutHelper.GetMessage("UPDATE", regionalOffice.RegionalOfficePK); return(RedirectToAction("Index", "RegionalOffice")); } else { return(View(regionalOfficeModel)); } }
public ActionResult Add(RegionalOfficeView regionalOfficeView) { if (ModelState.IsValid) { IRegionalOfficesRepository regionalOfficesRepository = new RegionalOfficesRepository(db); RegionalOffice regionalOffice = new RegionalOffice(); regionalOfficeView.ConvertTo(regionalOfficeView, regionalOffice); regionalOfficesRepository.Add(regionalOffice); regionalOfficesRepository.SaveChanges(); TempData["message"] = LayoutHelper.GetMessage("INSERT", regionalOffice.RegionalOfficePK); return(RedirectToAction("Index", "RegionalOffice")); } else { return(View(regionalOfficeView)); } }
public void ConvertTo(RegionalOfficeView regionalOfficeView, RegionalOffice regionalOffice) { regionalOffice.RegionalOfficePK = regionalOfficeView.RegionalOfficePK; regionalOffice.Name = regionalOfficeView.Name; }
public void ConvertFrom(RegionalOffice regionalOffice, RegionalOfficeView regionalOfficeView) { regionalOfficeView.RegionalOfficePK = regionalOffice.RegionalOfficePK; regionalOfficeView.Name = regionalOffice.Name; regionalOfficeView.Deleted = regionalOffice.Deleted; }