public ActionResult EditFacility(int efa_key) { var model = new PutFacilityViewModel(); var response = _ealertFacilitiesService.GetDetails(efa_key); if (response != null) { model.Id = response.efa_key; model.UserFullName = response.AspNetUser.FirstName + " " + response.AspNetUser.LastName; model.UserKey = response.efa_user_key; model.Facility = response.efa_fac_key; //.facility.fac_key; } return(PartialView("_EditFacility", model)); }
public ActionResult EditFacility(PutFacilityViewModel model) { if (ModelState.IsValid) { if (_ealertFacilitiesService.IsAlreadyExists(model.UserKey, model.Facility, model.Id)) { ModelState.AddModelError("", "Facility (" + model.FacilityName + ") for this user already exist"); } else { var modelDetail = _ealertFacilitiesService.GetDetails(model.Id); modelDetail.efa_user_key = model.UserKey; modelDetail.efa_fac_key = model.Facility; modelDetail.efa_modified_by = User.Identity.GetUserId(); modelDetail.efa_is_active = true; modelDetail.efa_modified_date = DateTime.Now.ToEST(); _ealertFacilitiesService.Edit(modelDetail); return(Json(new { success = true })); } } return(Json(new { success = false, data = string.Join("<br/>", this.GetModalErrors().Values) })); }