예제 #1
0
        public void Delete(St_SectionsOfFactoryH ObjDelete)
        {
            var ObjToDelete = _context.St_SectionsOfFactoryHs.SingleOrDefault(m => m.CompanyID == ObjDelete.CompanyID && m.SectionsOfFactoryID == ObjDelete.SectionsOfFactoryID);

            if (ObjToDelete != null)
            {
                _context.St_SectionsOfFactoryHs.Remove(ObjToDelete);
            }
        }
예제 #2
0
        public void Update(St_SectionsOfFactoryH ObjUpdate)
        {
            var ObjToUpdate = _context.St_SectionsOfFactoryHs.FirstOrDefault(m => m.CompanyID == ObjUpdate.CompanyID && m.SectionsOfFactoryID == ObjUpdate.SectionsOfFactoryID);

            if (ObjToUpdate != null)
            {
                ObjToUpdate.ArabicName  = ObjUpdate.ArabicName;
                ObjToUpdate.EnglishName = ObjUpdate.EnglishName;
                ObjToUpdate.FactoryID   = ObjUpdate.FactoryID;
            }
        }
        public JsonResult Save(St_SectionsOfFactoryHVM ObjToSave)
        {
            MsgUnit Msg = new MsgUnit();

            try
            {
                var userId   = User.Identity.GetUserId();
                var UserInfo = _unitOfWork.User.GetMyInfo(userId);
                var St_SectionsOfFactoryObj = new St_SectionsOfFactoryH();
                St_SectionsOfFactoryObj.InsDateTime         = DateTime.Now;
                St_SectionsOfFactoryObj.InsUserID           = userId;
                St_SectionsOfFactoryObj.CompanyID           = UserInfo.fCompanyId;
                St_SectionsOfFactoryObj.SectionsOfFactoryID = ObjToSave.SectionsOfFactoryID;
                St_SectionsOfFactoryObj.FactoryID           = ObjToSave.FactoryID;
                if (String.IsNullOrEmpty(ObjToSave.EnglishName))
                {
                    ObjToSave.EnglishName = ObjToSave.ArabicName;
                }
                St_SectionsOfFactoryObj.ArabicName  = ObjToSave.ArabicName;
                St_SectionsOfFactoryObj.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_SectionsOfFactoryH.Add(St_SectionsOfFactoryObj);
                _unitOfWork.Complete();
                Msg.LastID = _unitOfWork.St_SectionsOfFactoryH.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 Delete(St_SectionsOfFactoryHVM ObjDelete)
        {
            MsgUnit Msg = new MsgUnit();

            try
            {
                var userId   = User.Identity.GetUserId();
                var UserInfo = _unitOfWork.User.GetMyInfo(userId);

                ObjDelete.CompanyID = UserInfo.fCompanyId;
                var St_SectionsOfFactoryObj = new St_SectionsOfFactoryH();
                St_SectionsOfFactoryObj.CompanyID           = UserInfo.fCompanyId;
                St_SectionsOfFactoryObj.SectionsOfFactoryID = ObjDelete.SectionsOfFactoryID;

                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_SectionsOfFactoryH.Delete(St_SectionsOfFactoryObj);
                _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));
            }
        }
예제 #5
0
 public void Add(St_SectionsOfFactoryH ObjSave)
 {
     _context.St_SectionsOfFactoryHs.Add(ObjSave);
 }