Ejemplo n.º 1
0
        public void Delete(St_MeasurementDetail ObjDelete)
        {
            var ObjToDelete = _context.St_MeasurementDetails.SingleOrDefault(m => m.CompanyID == ObjDelete.CompanyID && m.MeasurementDetailID == ObjDelete.MeasurementDetailID && m.MeasurementID == ObjDelete.MeasurementID);

            if (ObjToDelete != null)
            {
                _context.St_MeasurementDetails.Remove(ObjToDelete);
            }
        }
Ejemplo n.º 2
0
        public void Update(St_MeasurementDetail ObjUpdate)
        {
            var ObjToUpdate = _context.St_MeasurementDetails.FirstOrDefault(m => m.CompanyID == ObjUpdate.CompanyID && m.MeasurementDetailID == ObjUpdate.MeasurementDetailID && m.MeasurementID == ObjUpdate.MeasurementID);

            if (ObjToUpdate != null)
            {
                ObjToUpdate.ArabicName  = ObjUpdate.ArabicName;
                ObjToUpdate.EnglishName = ObjUpdate.EnglishName;
                ObjToUpdate.InsUserID   = ObjUpdate.InsUserID;
                ObjToUpdate.InsDateTime = ObjUpdate.InsDateTime;
            }
        }
Ejemplo n.º 3
0
        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));
            }
        }
Ejemplo n.º 4
0
        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));
            }
        }
Ejemplo n.º 5
0
 public void Add(St_MeasurementDetail ObjSave)
 {
     _context.St_MeasurementDetails.Add(ObjSave);
 }