Exemplo n.º 1
0
        /// <summary>
        /// Созлание записи в таблице модуля проводок
        /// </summary>
        /// <param name="account">DTO счета</param>
        /// <param name="request">Сущность комманды на создание счета</param>
        /// <param name="cancellationToken">Токе отмены</param>
        /// <returns></returns>
        public async Task <ResponseBaseDto> AddBuferEntry(AccountDto account,
                                                          CreateAccountHistoryEntryCommand request,
                                                          CancellationToken cancellationToken)
        {
            var emptyAccount = "00000000000000000000";

            if (request.IsTopUp)
            {
                await _accountHistoryBufferRepository.AddBufferEntry(new BufferForFutureEntriesDatesModel(emptyAccount,
                                                                                                          request.AccountNumber,
                                                                                                          request.Amount,
                                                                                                          request.DueDate.Date,
                                                                                                          request.OperationId,
                                                                                                          0,
                                                                                                          request.AccountType,
                                                                                                          request.Description));
            }
            else
            {
                await _accountHistoryBufferRepository.AddBufferEntry(new BufferForFutureEntriesDatesModel(request.AccountNumber,
                                                                                                          emptyAccount,
                                                                                                          request.Amount,
                                                                                                          request.DueDate.Date,
                                                                                                          request.OperationId,
                                                                                                          request.AccountType,
                                                                                                          0,
                                                                                                          request.Description ));
            }
            await _accountHistoryBufferRepository.SaveChangesAsync();

            return(_baseHelper.FormMessageResponse(ok, message));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Созлание записи в журнале проводок
        /// </summary>
        /// <param name="account">DTO счета</param>
        /// <param name="request">Сущность комманды создания записи в журнале проводки</param>
        /// <param name="cancellationToken">Токен отмены</param>
        /// <returns></returns>
        public async Task <ResponseBaseDto> CreateAccountHistorySoloEntry(AccountDto account,
                                                                          CreateAccountHistoryEntryCommand request,
                                                                          CancellationToken cancellationToken)
        {
            if (account == null)
            {
                var createdAccount = _baseHelper.InitiateAccount(request.AccountNumber, request.AccountType, false);
                return(await _helper.FormAccountEntryResponse(createdAccount, request.OperationId, request.Amount, request.IsTopUp, request.DueDate, request.Description, false));
            }

            return(await _helper.FormAccountEntryResponse(account, request.OperationId, request.Amount, request.IsTopUp, request.DueDate, request.Description, true));
        }
        public async Task <ActionResult> TopUpAccount([FromBody] AmountOneDto account)
        {
            var accountCommand = new CreateAccountHistoryEntryCommand(account.AccountNumber, Convert.ToDecimal(account.CurrentAmount), true, account.DueDate, account.AccountType, account.OperationId, account.Description);

            return(Ok(await CommandAsync(accountCommand)));
        }