public void Delete(St_BranchH ObjDelete) { var ObjToDelete = Context.St_BrancheHs.SingleOrDefault(m => m.CompanyID == ObjDelete.CompanyID && m.BranchCode == ObjDelete.BranchCode); if (ObjToDelete != null) { Context.St_BrancheHs.Remove(ObjToDelete); } }
public JsonResult Update(St_BranchHVM ObjUpdate) { MsgUnit Msg = new MsgUnit(); try { var userId = User.Identity.GetUserId(); var UserInfo = _unitOfWork.User.GetMyInfo(userId); var ObjUpdateBranch = new St_BranchH(); ObjUpdateBranch.InsDateTime = DateTime.Now; ObjUpdateBranch.InsUserID = userId; ObjUpdateBranch.CompanyID = UserInfo.fCompanyId; ObjUpdateBranch.BranchCode = ObjUpdate.BranchCode; ObjUpdateBranch.BranchStockCode = ObjUpdate.BranchStockCode; ObjUpdateBranch.MainStockCode = ObjUpdate.MainStockCode; ObjUpdateBranch.Telephone = ObjUpdate.Telephone; ObjUpdateBranch.Address = ObjUpdate.Address; ObjUpdateBranch.ArabicName = ObjUpdate.ArabicName; if (String.IsNullOrEmpty(ObjUpdate.EnglishName)) { ObjUpdateBranch.EnglishName = ObjUpdateBranch.ArabicName; } else { ObjUpdateBranch.EnglishName = ObjUpdate.EnglishName; } 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_BranchH.Update(ObjUpdateBranch); _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)); } }
public void Update(St_BranchH ObjUpdate) { var ObjToUpdate = Context.St_BrancheHs.FirstOrDefault(m => m.CompanyID == ObjUpdate.CompanyID && m.BranchCode == ObjUpdate.BranchCode); if (ObjToUpdate != null) { ObjToUpdate.ArabicName = ObjUpdate.ArabicName; ObjToUpdate.EnglishName = ObjUpdate.EnglishName; ObjToUpdate.MainStockCode = ObjUpdate.MainStockCode; ObjToUpdate.BranchStockCode = ObjUpdate.BranchStockCode; ObjToUpdate.Address = ObjUpdate.Address; ObjToUpdate.Telephone = ObjUpdate.Telephone; ObjToUpdate.InsDateTime = ObjUpdate.InsDateTime; ObjToUpdate.InsUserID = ObjUpdate.InsUserID; } }
public JsonResult Delete(St_BranchHVM ObjDelete) { MsgUnit Msg = new MsgUnit(); try { var userId = User.Identity.GetUserId(); var UserInfo = _unitOfWork.User.GetMyInfo(userId); ObjDelete.CompanyID = UserInfo.fCompanyId; var ObjDeleteSt_Branch = new St_BranchH(); ObjDeleteSt_Branch.CompanyID = UserInfo.fCompanyId; ObjDeleteSt_Branch.BranchCode = ObjDelete.BranchCode; var ObjDeleteSt_BranchAccount = new St_BranchAccountH(); ObjDeleteSt_BranchAccount.CompanyID = UserInfo.fCompanyId; ObjDeleteSt_BranchAccount.BranchCode = ObjDelete.BranchCode; 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.NativeSql.DeleteSt_BranchExpenseAccountH(ObjDeleteSt_Branch.CompanyID, ObjDeleteSt_Branch.BranchCode); _unitOfWork.NativeSql.DeleteSt_BranchOtherExpenseAccountH(ObjDeleteSt_Branch.CompanyID, ObjDeleteSt_Branch.BranchCode); _unitOfWork.St_BranchAccountH.Delete(ObjDeleteSt_BranchAccount); _unitOfWork.St_BranchH.Delete(ObjDeleteSt_Branch); _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_BranchH ObjSave) { Context.St_BrancheHs.Add(ObjSave); }