Пример #1
0
        public List <string> ValidateLoginRequirement(LoginViewModel model)
        {
            //Check if the user password is expired
            if (DateTime.UtcNow.Date >= _accountRepository.GetPasswordExpiryDate(model.Username))
            {
                _validationDictionary.AddError(_config.GetSection("Messages")["ExpiredPassword"]);
            }

            //Check if End of day is in progress
            if (_accountRepository.GetUserStatus(model.Username).Contains("EOD"))
            {
                _validationDictionary.AddError(_config.GetSection("Messages")["EODInProgress"]);
            }

            //Check if the user is Active or not
            if (_accountRepository.GetUserStatus(model.Username) == "DISABLED" || _accountRepository.GetUserStatus(model.Username) == "PENDING")
            {
                _validationDictionary.AddError(_config.GetSection("Messages")["UserDisabled"]);
            }

            //This checks if the user is logged in already
            if (_accountRepository.UserIsLoggedIn(model.Username))
            {
                _validationDictionary.AddError(string.Format(_config.GetSection("Messages")["UserLoggedIn"], model.Username));
            }

            return(_validationDictionary.GetValidationErrors());
        }
Пример #2
0
        public async Task <IActionResult> CashDeposit(TransactionViewModel model)
        {
            if (!ModelState.IsValid)
            {
                model = new TransactionViewModel {
                    StatusMessage = "Please correct the errors"
                };
                //SetCustomerAccountViewItems();
                return(View(model));
            }

            var user = await _userManager.GetUserAsync(User);

            var requirementResult = _cashService.ValidateCashDepositRequirement(model, user.UserName);

            if (requirementResult != null)
            {
                foreach (var error in _validationDictionary.GetValidationErrors())
                {
                    model = new TransactionViewModel {
                        StatusMessage = error
                    };
                    return(View(model));
                }
            }

            //If here, then its a new branch
            Result = await _cashService.CreateCashDepositAsync(model, user.UserName);

            if (Result.Equals("Succeeded"))
            {
                StatusMessage = _config.GetSection("Messages")["Success"];
                return(RedirectToAction(nameof(CashDeposit)));
            }
            else
            {
                StatusMessage = "Error: Unable to create deposit transaction";
                return(View(model));
            }
        }
Пример #3
0
        //Deposit transactions
        #region
        public async Task <List <string> > ValidateCashDepositRequirement(TransactionViewModel model, string username)
        {
            //This checks if the credit account exist
            if (_cashRepository.CheckIfAccountExist(model.CR) == null)
            {
                _validationDictionary.AddError(string.Format(_config.GetSection("Messages")["InvalidAccount"], "Credit ", model.CR));
            }

            //This checks if the account is active or not
            if (_cashRepository.CheckAccountStatus(model.CR) != "ACTIVE")
            {
                _validationDictionary.AddError(string.Format(_config.GetSection("Messages")["DisabledAccount"], model.CR));
            }

            //This checks for same account
            if (model.DR == model.CR)
            {
                _validationDictionary.AddError(_config.GetSection("Messages")["SameAccount"]);
            }

            //This checks post no credit on the customer account
            if (_cashRepository.CheckPostNoCredit(model.CR))
            {
                _validationDictionary.AddError(string.Format(_config.GetSection("Messages")["PostNoCredit"], model.CR));
            }

            //This checks the transaction limit set on the account
            if (_cashRepository.CheckCashDepositAmountLimitReached(model.CR))
            {
                _validationDictionary.AddError(string.Format(_config.GetSection("Messages")["TransactionLimitReached"], model.CR));
            }

            //This checks the transaction limit set on the account
            if (_cashRepository.CheckCashDepositTransactionLimitReached(model.CR))
            {
                _validationDictionary.AddError(string.Format(_config.GetSection("Messages")["TransactionLimitReached"], model.CR));
            }

            //This checks the limit of cash transaction allowed for the user
            if (_cashRepository.TransactionLimitReached(username, model.Amount))
            {
                _validationDictionary.AddError(string.Format(_config.GetSection("Messages")["PostingLimitReached"], model.Amount));
            }

            //This checks if Interbranch transaction
            string debitBranch  = _cashRepository.GetBranchCodeFromAccountNo(model.DR);
            string creditBranch = _cashRepository.GetBranchCodeFromAccountNo(model.CR);

            if (debitBranch != creditBranch)
            {
                if (!_cashRepository.InterBranchAccountExist(model.DR, model.CR))
                {
                    _validationDictionary.AddError(string.Format(_config.GetSection("Messages")["NoInterBranchAccount"], model.CR));
                }

                //This checks if user has Inter Branch role
                bool userHasRole = await _cashRepository.CheckIfUserHasRole(username);

                if (!userHasRole)
                {
                    _validationDictionary.AddError(_config.GetSection("Messages")["NoInterBranchRole"]);
                }

                //This checks if the liability account in the destination branch is created
                if (_cashRepository.GetLiabilityAccountNo(_cashRepository.GetProductCodeFromAccountNo(model.CR), _cashRepository.GetBranchCodeFromAccountNo(model.CR)) == null)
                {
                    _validationDictionary.AddError(_config.GetSection("Messages")["NoLiabilityAccount"]);
                }
            }

            //This checks if the user is a Teller (Has a Teller account) in the form TELLER USERNAME
            if (!_cashRepository.CheckIfTeller(username))
            {
                _validationDictionary.AddError(_config.GetSection("Messages")["NotTeller"]);
            }

            return(_validationDictionary.GetValidationErrors());
        }