public ActionResult OtherPermitsEdit(int PermitKey, OtherPermitsVM model) { if (!ModelState.IsValid) return PartialView("OtherPermitsAddEdit", model); try { ContactDO data = model.GetDataObject(); ContactBLL.SaveContact(data); AddressDO addressdata = model.GetAddressDataObject(); ContactBLL.SaveAddress(addressdata); AjaxResult result = new AjaxResult(AjaxResult.AjaxStatus.OK, "Contact and address was saved"); return Json(result); } catch (Exception ex) { AjaxResult result = new AjaxResult(AjaxResult.AjaxStatus.ERROR, ex.Message); return Json(result); } }
public ActionResult OtherPermitsAdd(OtherPermitsVM model) { AddressDO addressdata = model.GetAddressDataObject(); if (string.IsNullOrEmpty(addressdata.City) && string.IsNullOrEmpty(addressdata.StateID)) { ModelState.Remove("Address11"); ModelState.Remove("City"); ModelState.Remove("StateID"); ModelState.Remove("ZipCode"); } if (!ModelState.IsValid) return PartialView("OtherPermitsAddEdit", model); try { ContactDO data = model.GetDataObject(); addressdata.ContactID = ContactBLL.SaveContact(data); if (!string.IsNullOrEmpty(addressdata.City) && !string.IsNullOrEmpty(addressdata.StateID)) ContactBLL.SaveAddress(addressdata); AjaxResult result = new AjaxResult(AjaxResult.AjaxStatus.OK, "Contact and address was saved"); return Json(result); } catch (Exception ex) { AjaxResult result = new AjaxResult(AjaxResult.AjaxStatus.ERROR, ex.Message); return Json(result); } }