public ActionResult Add() { PostalOfficeView postalOfficeView = new PostalOfficeView(); // set default country to Croatia postalOfficeView.CountryFK = 81; postalOfficeView.BindDDLs(postalOfficeView, db); return(View(postalOfficeView)); }
public ActionResult Edit(int?postalOfficePK) { if (postalOfficePK != null) { IPostalOfficesRepository postalOfficesRepository = new PostalOfficesRepository(db); PostalOffice postalOffice = postalOfficesRepository.GetPostalOfficeByPK((int)postalOfficePK); PostalOfficeView postalOfficeView = new PostalOfficeView(); postalOfficeView.ConvertFrom(postalOffice, postalOfficeView, db); postalOfficeView.BindDDLs(postalOfficeView, db); return(View(postalOfficeView)); } else { return(RedirectToAction("Index", "PostalOffice")); } }
public ActionResult Edit(PostalOfficeView postalOfficeView, FormCollection form) { if (ModelState.IsValid) { IPostalOfficesRepository postalOfficesRepository = new PostalOfficesRepository(db); PostalOffice postalOffice = postalOfficesRepository.GetPostalOfficeByPK((int)postalOfficeView.PostalOfficePK); postalOfficeView.ConvertTo(postalOfficeView, postalOffice); postalOfficesRepository.SaveChanges(); TempData["message"] = LayoutHelper.GetMessage("UPDATE", postalOffice.PostalOfficePK); return(RedirectToAction("Index", "PostalOffice")); } else { postalOfficeView.BindDDLs(postalOfficeView, db); return(View(postalOfficeView)); } }