public ActionResult Add() { CountyView countyView = new CountyView(); countyView.BindDDLs(countyView, db); return(View(countyView)); }
public ActionResult Edit(int?countyPK) { if (countyPK != null) { ICountiesRepository countiesRepository = new CountiesRepository(db); County county = countiesRepository.GetCountyByPK((int)countyPK); CountyView countyView = new CountyView(); countyView.ConvertFrom(county, countyView); countyView.BindDDLs(countyView, db); return(View(countyView)); } else { return(RedirectToAction("Index", "County")); } }
public ActionResult Edit(CountyView countyView, FormCollection form) { if (ModelState.IsValid) { ICountiesRepository countiesRepository = new CountiesRepository(db); County county = countiesRepository.GetCountyByPK((int)countyView.CountyPK); countyView.ConvertTo(countyView, county); countiesRepository.SaveChanges(); TempData["message"] = LayoutHelper.GetMessage("UPDATE", county.CountyPK); return(RedirectToAction("Index", "County")); } else { countyView.BindDDLs(countyView, db); return(View(countyView)); } }