public JsonResult Edit(SubMaterialViewModel model) { try { var item = Mapper.Map <SubMaterialItem>(model); var isSuccess = _subMaterialDomain.CreateOrUpdate(item); if (!isSuccess.IsSuccess) { return(Json(new { Success = false, Message = isSuccess.ErrorMessages }, JsonRequestBehavior.AllowGet)); } return (Json( new { Success = true, Message = model.IsCreate ? MessageResource.MSG6 : MessageResource.MSG9 }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { Success = false, ex.Message }, JsonRequestBehavior.AllowGet)); } }
public ActionResult Edit(string id) { var model = new SubMaterialViewModel { IsCreate = true }; if (!string.IsNullOrEmpty(id)) { var entity = _subMaterialDomain.GetById(id.Trim()); if (entity != null) { model = Mapper.Map <SubMaterialViewModel>(entity); model.IsCreate = false; } } return(PartialView("SubMaterialMaster/_PartialSubMaterial", model)); }