コード例 #1
0
        public async Task <IActionResult> CreatePayment([FromBody] CreatePayment model)
        {
            var meterRead = await _serviceClient.GetMeterRead(model.MeterReadId);

            await _paymentDomainService.CreatePayment(model.MeterReadId, model.AddressId, meterRead.Usages.Select(Convert).ToList());

            return(StatusCode(200, model.PaymentId));
        }
コード例 #2
0
        public async Task Consume(ConsumeContext <IMeterReadProcessFinished> context)
        {
            var meterRead = await _billsServiceClient.GetMeterRead(context.Message.MeterReadId);

            if (meterRead == null)
            {
                throw new MeterReadNotFoundException(context.Message.MeterReadId.ToString());
            }

            if (!meterRead.Usages.Any())
            {
                throw new NoUsagesExistInMeterReadException(context.Message.MeterReadId.ToString());
            }

            await _paymentDomainService.CreatePayment(context.Message.MeterReadId, context.Message.AddressId,
                                                      meterRead.Usages?.Select(Convert).ToList());

            await _documentSession.SaveChangesAsync();

            await context.Publish <IPaymentAccepted>(
                new { PaymentId = context.Message.MeterReadId, AddressId = context.Message.AddressId });
        }