public async Task CreateNewBankAccountAsync(int userId, string accountName, decimal initialBalance, string currency, string hexColor)
        {
            var user = await _userRepository.GetOrFailAsync(userId);

            var newBankAcc = user.CreateBankAccount(await _bankAccountRepository.NextId(), accountName, initialBalance, currency, hexColor);
            await _bankAccountRepository.AddAsync(newBankAcc);
        }
Ejemplo n.º 2
0
        public async Task AddAsync(SalesTaxAddModel model)
        {
            var result = await _bankAccountRepository.getAccountTypeByCode();

            var bankAcc = SalesTaxFactory.AccountCreate(model, _userId, result.KeyInt);
            await _bankAccountRepository.AddAsync(bankAcc);

            await _unitOfWork.SaveChangesAsync();

            await _repository.AddAsync(SalesTaxFactory.Create(model, _userId, bankAcc.Id));

            await _unitOfWork.SaveChangesAsync();
        }
        public override async Task <bool> HandleCommandAsync(CreateBankAccountCommand request, CancellationToken cancellationToken)
        {
            try
            {
                var account = new BankAccount();
                await _bankAccountRepository.AddAsync(account);

                return(true);
            }
            catch
            {
                return(false);
            }
        }
Ejemplo n.º 4
0
        public async Task AddAsync(BankAccountAddModel model)
        {
            var result = BankAccountFactory.Create(model, _userId);

            await _bankAccountRepository.AddAsync(result);

            if (model.COA_AccountTypeId == 1 || model.COA_AccountTypeId == 2 || model.COA_AccountTypeId == 6 || model.COA_AccountTypeId == 7)
            {
                Reconciliation reconciliation = new Reconciliation();
                ReconciliationFactory.Create(result.Id, reconciliation);
                await _reconciliationRepository.AddAsync(reconciliation);
            }
            await _unitOfWork.SaveChangesAsync();
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Add or Edit bank account
        /// </summary>
        /// <param name="accountId"></param>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task <Response> AddOrEditBankAccountAsync(int accountId, CreateBankAccountRequest request,
                                                               CancellationToken cancellationToken = default)
        {
            var responseModel = new Response();

            if (accountId > 0)
            {
                var bankaccount = await _bankAccountRepo.FindByIdAsync(accountId);

                if (bankaccount != null)
                {
                    bankaccount.IBAN           = request.IBAN;
                    bankaccount.CurrencyId     = request.CurrencyId;
                    bankaccount.Balance        = request.Balance;
                    bankaccount.Type           = request.Type;
                    bankaccount.LastModifiedBy = _httpContextAccessor.HttpContext.User.Identity.Name;
                    bankaccount.LastModifiedOn = DateTime.UtcNow;

                    await _bankAccountRepo.UpdateAsync(bankaccount);
                }
                else
                {
                    responseModel.AddError(ExceptionCreator.CreateNotFoundError("bankAccount", $"bank account Not found"));
                    return(responseModel);
                }
            }
            else
            {
                try
                {
                    var newBankAccount = CreateBankAccount(request);

                    await _bankAccountRepo.AddAsync(newBankAccount);
                }
                catch (Exception ex)
                {
                    responseModel.AddError(ExceptionCreator.CreateInternalServerError(ex.ToString()));
                }
            }

            return(responseModel);
        }
        public async Task AddAsync(BankAccountAddModel model)
        {
            await _bankAccountRepository.AddAsync(BankAccountFactory.Create(model, _userId));

            await _unitOfWork.SaveChangesAsync();
        }