Пример #1
0
        public IActionResult Insert()
        {
            ViewBag.showMsg = false;
            PaymentBalanceVM paymentBalanceVM = new PaymentBalanceVM()
            {
                paymentBalances = new PaymentBalance(),

                UsersList = _unitOfWork.ApplicationUser.GeAllUsersWithoutrecInPayBalance().Select(i => new SelectListItem
                {
                    Text  = i.Name + "-" + i.UserName,
                    Value = i.Id.ToString()
                })
            };

            return(View(paymentBalanceVM));
        }
Пример #2
0
        public IActionResult Insert(PaymentBalanceVM paymentBalanceVM)
        {
            var appUser = _unitOfWork.ApplicationUser.GetAll().Where(a => a.Id == paymentBalanceVM.paymentBalances.UserNameId).FirstOrDefault();

            if (appUser.Role == SD.Role_Warehouse)
            {
                paymentBalanceVM.paymentBalances.IsWarehouseBalance = true;
            }
            ViewBag.showMsg            = true;
            paymentBalanceVM.UsersList = _unitOfWork.ApplicationUser.GeAllUsersWithoutrecInPayBalance().Select(i => new SelectListItem
            {
                Text  = i.UserName,
                Value = i.Id.ToString()
            });
            if (ModelState.IsValid)
            {
                _unitOfWork.PaymentBalance.Add(paymentBalanceVM.paymentBalances);
                _unitOfWork.Save();
                ViewBag.Success = true;
                return(View(paymentBalanceVM));
            }
            ViewBag.Success = false;
            return(View(paymentBalanceVM));
        }