public ActionResult Location(LocationVM Model, int PermitKey) { // reload counties and quads from business logic because they aren't available in the posted view model LocationBO LocationBo = PermitBLL.GetLocation(PermitKey); Model.Counties = LocationBo.Counties; Model.Quadrangles = LocationBo.Quadrangles; // don't proceed if the model is invalid (server side validation) if (!ModelState.IsValid) return View(Model); // if the model is valid, attempt to save it try { LocationBO location = Model.GetDataObject(); // get the data object from the view model PermitBLL.SaveLocation(location); // save the data object using the business logic layer AddSuccessMessage("Your changes have been saved"); // notify the user the save was successful } catch (Exception ex) { AddErrorMessage(ex); // notify the user the save failed, and display the error message } // return the view model to the view (displays the data we just saved and shows notification to user) return View(Model); }
public ActionResult Location(int PermitKey) { LocationBO LocationBo = PermitBLL.GetLocation(PermitKey); LocationVM Location = new LocationVM(LocationBo); return View(Location); }