示例#1
0
        public IActionResult CreatePVs()
        {
            var currentRoleId = _partnerManager.GetCurrentUserRole(this.HttpContext);
            var permission    = _partActRepo.GetPartAct("PayemntValues.Create", currentRoleId);

            if (permission == null)
            {
                _toastNotification.AddErrorToastMessage("ليس لديك الصلاحيات الكافية", new ToastrOptions {
                    Title = ""
                });
                return(Redirect(Request.Headers["Referer"].ToString()));
            }

            var model = new PaymentValuesDto();

            return(View(model));
        }
示例#2
0
        public IActionResult CreatePVs(PaymentValuesDto model)
        {
            if (ModelState.IsValid)
            {
                if (model.PayValue <= 0)
                {
                    _toastNotification.AddErrorToastMessage("المبلغ غير صحيح", new ToastrOptions {
                        Title = ""
                    });
                    return(View());
                }
                if (model.ProfileId <= 0)
                {
                    _toastNotification.AddErrorToastMessage("رقم المعرف غير صحيح", new ToastrOptions {
                        Title = ""
                    });
                    return(View());
                }
                var created = new PaymentValues();
                created.PayValue          = model.PayValue;
                created.ProfileId         = model.ProfileId;
                created.CreatedBy.Id      = _partnerManager.GetCurrentUserId(httpContext: this.HttpContext);
                created.CreatedBy.Account = _partnerManager.GetCurrentUserAccount(httpContext: this.HttpContext);
                var result = new PaymentValuesRepo(_db, _partnerManager).Create(created);
                if (!result.Success)
                {
                    if (result.AffectedCount == -504)
                    {
                        _toastNotification.AddErrorToastMessage($"المبلغ {model.PayValue.ToString("N2")} موجود مسبقا", new ToastrOptions {
                            Title = ""
                        });
                        return(Redirect(Request.Headers["Referer"].ToString()));
                    }
                }

                PValues();
                return(View("PValues"));
            }
            else
            {
                return(View());
            }
        }