Exemple #1
0
        public void Update(St_ExtraExpense ObjUpdate)
        {
            var ObjToUpdate = _context.St_ExtraExpenses.SingleOrDefault(m => m.CompanyID == ObjUpdate.CompanyID && m.ExtraExpenseID == ObjUpdate.ExtraExpenseID);

            if (ObjToUpdate != null)
            {
                ObjToUpdate.ArabicName  = ObjUpdate.ArabicName;
                ObjToUpdate.EnglishName = ObjUpdate.EnglishName;
            }
        }
        public JsonResult UpdateExtraExpense(St_ExtraExpense ObjUpdate)
        {
            MsgUnit Msg = new MsgUnit();

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

                ObjUpdate.CompanyID = UserInfo.fCompanyId;
                if (String.IsNullOrEmpty(ObjUpdate.EnglishName))
                {
                    ObjUpdate.EnglishName = ObjUpdate.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_ExtraExpense.Update(ObjUpdate);
                _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));
            }
        }