public void Update(St_Description ObjUpdate) { var ObjToUpdate = _context.St_Descriptions.SingleOrDefault(m => m.CompanyID == ObjUpdate.CompanyID && m.DescriptionID == ObjUpdate.DescriptionID); if (ObjToUpdate != null) { ObjToUpdate.ArabicName = ObjUpdate.ArabicName; ObjToUpdate.EnglishName = ObjUpdate.EnglishName; } }
public JsonResult UpdateDescription(St_Description ObjUpdate) { MsgUnit Msg = new MsgUnit(); try { var userId = User.Identity.GetUserId(); var UserInfo = _unitOfWork.User.GetMyInfo(userId); ObjUpdate.CompanyID = UserInfo.fCompanyId; if (String.IsNullOrEmpty(ObjUpdate.EnglishName)) { ObjUpdate.EnglishName = ObjUpdate.ArabicName; } if (!ModelState.IsValid) { string Err = " "; var errors = ModelState.Values.SelectMany(v => v.Errors); foreach (ModelError error in errors) { Err = Err + error.ErrorMessage + " * "; } Msg.Msg = Resources.Resource.SomthingWentWrong + " : " + Err; Msg.Code = 0; return(Json(Msg, JsonRequestBehavior.AllowGet)); } _unitOfWork.St_Description.Update(ObjUpdate); _unitOfWork.Complete(); Msg.Code = 1; Msg.Msg = Resources.Resource.UpdatedSuccessfully; return(Json(Msg, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { Msg.Msg = Resources.Resource.SomthingWentWrong + " : " + ex.Message.ToString(); Msg.Code = 0; return(Json(Msg, JsonRequestBehavior.AllowGet)); } }