public void Update(St_ItemUnit ObjUpdate) { var ObjToUpdate = _context.St_ItemUnits.FirstOrDefault(m => m.CompanyID == ObjUpdate.CompanyID && m.ItemUnitCode == ObjUpdate.ItemUnitCode); if (ObjToUpdate != null) { ObjToUpdate.ArabicName = ObjUpdate.ArabicName; ObjToUpdate.EnglishName = ObjUpdate.EnglishName; ObjToUpdate.InsDateTime = ObjUpdate.InsDateTime; ObjToUpdate.InsUserID = ObjUpdate.InsUserID; } }
public JsonResult SaveSt_ItemUnit(St_ItemUnit ObjSave) { MsgUnit Msg = new MsgUnit(); try { var userId = User.Identity.GetUserId(); var UserInfo = _unitOfWork.User.GetMyInfo(userId); ObjSave.ItemUnitCode = _unitOfWork.St_ItemUnit.GetMaxSerial(UserInfo.fCompanyId); ObjSave.InsDateTime = DateTime.Now; ObjSave.InsUserID = userId; ObjSave.CompanyID = UserInfo.fCompanyId; if (String.IsNullOrEmpty(ObjSave.EnglishName)) { ObjSave.EnglishName = ObjSave.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_ItemUnit.Add(ObjSave); _unitOfWork.Complete(); Msg.LastID = _unitOfWork.St_ItemUnit.GetMaxSerial(UserInfo.fCompanyId).ToString(); Msg.Code = 1; Msg.Msg = Resources.Resource.AddedSuccessfully; return(Json(Msg, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { Msg.Msg = Resources.Resource.SomthingWentWrong + " : " + ex.Message.ToString(); Msg.Code = 0; return(Json(Msg, JsonRequestBehavior.AllowGet)); } }
public JsonResult DeleteSt_ItemUnit(St_ItemUnit ObjDelete) { MsgUnit Msg = new MsgUnit(); try { var userId = User.Identity.GetUserId(); var UserInfo = _unitOfWork.User.GetMyInfo(userId); ObjDelete.CompanyID = UserInfo.fCompanyId; 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_ItemUnit.Delete(ObjDelete); _unitOfWork.Complete(); Msg.Code = 1; Msg.Msg = Resources.Resource.DeletedSuccessfully; return(Json(Msg, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { Msg.Msg = Resources.Resource.SomthingWentWrong + " : " + ex.Message.ToString(); Msg.Code = 0; return(Json(Msg, JsonRequestBehavior.AllowGet)); } }
public void Add(St_ItemUnit ObjSave) { _context.St_ItemUnits.Add(ObjSave); }