コード例 #1
0
        public async Task <CreditPayment> CreateCreditPaymentAsync(CreditPaymentRequest request, int creditId, string userId)
        {
            var paymentDto = new CreditPaymentDto
            {
                CreatedDate  = DateTime.UtcNow,
                PaymentDate  = request.PaymentDate,
                PaymentValue = request.PaymentValue,
                CurrencyId   = request.CurrencyId,
                CreditId     = creditId,
                PeriodId     = request.PeriodId,
                UserId       = userId
            };

            var payment = _mapper.Map <CreditPayment>(paymentDto);

            return(await _baseRepository.CreateEntityAsync(payment));
        }
コード例 #2
0
        public async Task <CommandResult> AddPaymentAsync(AddPaymentCommand command)
        {
            var rightsRes = await CheckEmployeeRightsAsync(command.EmployeeId, EmployeeRights.Cashier);

            var employeeRes = await GetEmployeeAsync(command.EmployeeId);

            var accountRes = await GetCreditAccountAsync(command.CreditAccountId);

            var res = CheckPayment(rightsRes, employeeRes, accountRes, command.PaymentSum);

            if (res.IsFailed)
            {
                return(new CommandResult(command, false).From(res));
            }
            var payment = new CreditPaymentDto
            {
                Timestamp     = DateTime.Now,
                PaymentSum    = command.PaymentSum,
                CreditAccount = accountRes.Value,
                Employee      = employeeRes.Value
            };
            var paymentRes = await _creditPaymentService.CreateModelAsync(payment);

            if (paymentRes.IsFailed)
            {
                return(new CommandResult(command, false).From(paymentRes));
            }
            var action = new PaymentActionDto
            {
                Timestamp     = DateTime.Now,
                Employee      = employeeRes.Value,
                CreditPayment = payment,
                ActionType    = GetActionType(command.GetType().Name)
            };

            action.Signature = GetPaymentSignature(action);
            await _paymentActionService.CreateModelAsync(action);

            return(new CommandResult(command, true));
        }