public ActionResult Delete(int id, int id2) { try { if (id != 0) { var userId = User.Identity.GetUserId(); var UserInfo = _unitOfWork.User.GetUserByID(userId); if (UserInfo == null) { RedirectToAction("", ""); } var Obj = _unitOfWork.St_MeasurementDetail.GetSt_MeasurementDetailByID(UserInfo.fCompanyId, id, id2); var St_MeasurementDetailObj = new St_MeasurementDetailVM(); St_MeasurementDetailObj.St_Measurement = _unitOfWork.NativeSql.GetAllSt_Measurement(UserInfo.fCompanyId); St_MeasurementDetailObj.MeasurementID = Obj.MeasurementID; St_MeasurementDetailObj.MeasurementDetailID = Obj.MeasurementDetailID; St_MeasurementDetailObj.ArabicName = Obj.ArabicName; St_MeasurementDetailObj.EnglishName = Obj.EnglishName; return(PartialView("Delete", St_MeasurementDetailObj)); } return(PartialView("Delete", new St_MeasurementDetailVM())); } catch (Exception ex) { ViewBag.Error = ex.Message.ToString(); return(View("Error")); } }
public ActionResult Add() { var userId = User.Identity.GetUserId(); var UserInfo = _unitOfWork.User.GetMyInfo(userId); St_MeasurementDetailVM Obj = new St_MeasurementDetailVM { St_Measurement = _unitOfWork.NativeSql.GetAllSt_Measurement(UserInfo.fCompanyId), MeasurementID = 1 }; return(PartialView(Obj)); }
public JsonResult SaveSt_MeasurementDetail(St_MeasurementDetailVM ObjToSave) { MsgUnit Msg = new MsgUnit(); try { var userId = User.Identity.GetUserId(); var UserInfo = _unitOfWork.User.GetMyInfo(userId); var St_MeasurementDetailObj = new St_MeasurementDetail(); St_MeasurementDetailObj.InsDateTime = DateTime.Now; St_MeasurementDetailObj.InsUserID = userId; St_MeasurementDetailObj.CompanyID = UserInfo.fCompanyId; St_MeasurementDetailObj.MeasurementID = ObjToSave.MeasurementID; St_MeasurementDetailObj.MeasurementDetailID = _unitOfWork.St_MeasurementDetail.GetMaxSerial(UserInfo.fCompanyId, St_MeasurementDetailObj.MeasurementID); if (String.IsNullOrEmpty(ObjToSave.EnglishName)) { ObjToSave.EnglishName = ObjToSave.ArabicName; } St_MeasurementDetailObj.ArabicName = ObjToSave.ArabicName; St_MeasurementDetailObj.EnglishName = ObjToSave.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_MeasurementDetail.Add(St_MeasurementDetailObj); _unitOfWork.Complete(); 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_MeasurementDetail(St_MeasurementDetailVM ObjDelete) { MsgUnit Msg = new MsgUnit(); try { var userId = User.Identity.GetUserId(); var UserInfo = _unitOfWork.User.GetMyInfo(userId); ObjDelete.CompanyID = UserInfo.fCompanyId; var St_MeasurementDetailObj = new St_MeasurementDetail(); St_MeasurementDetailObj.CompanyID = UserInfo.fCompanyId; St_MeasurementDetailObj.MeasurementID = ObjDelete.MeasurementID; St_MeasurementDetailObj.MeasurementDetailID = ObjDelete.MeasurementDetailID; 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_MeasurementDetail.Delete(St_MeasurementDetailObj); _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)); } }