コード例 #1
0
        public async Task <ServiceResponse <Payment> > UpdatePayment(UpdatePaymentDto updatePayment)
        {
            ServiceResponse <Payment> serviceResponse = new ServiceResponse <Payment>();

            try
            {
                var updatedPayment = _context.Payments.First(p => p.Id == updatePayment.Id);
                if (updatePayment.isTerminated)
                {
                    updatedPayment.PaymentTermination = DateTime.Now;
                    updatedPayment.StartDate          = DateTime.Now;
                    _context.SaveChanges();
                    serviceResponse.Data = updatedPayment;
                }
                else
                {
                    serviceResponse.Data = null;
                }
            }
            catch (Exception ex)
            {
                serviceResponse.Success = false;
                serviceResponse.Message = (ex.InnerException != null) ? ex.InnerException.Message : ex.Message;
            }
            return(serviceResponse);
        }
コード例 #2
0
 public async Task UpdatePayment(UpdatePaymentDto input)
 {
     long sellerId = (await GetCurrentSeller()).Id;
     await SellerManager.UpdatePayment(
         sellerId,
         input.Payload,
         input.SellerPaymentOption
         );
 }
コード例 #3
0
        public async Task <IActionResult> UpdatePayment(UpdatePaymentDto updatePayment)
        {
            ServiceResponse <Payment> response = await _paymentService.UpdatePayment(updatePayment);

            if (response.Data == null)
            {
                return(NotFound(response));
            }
            return(Ok(response));
        }
コード例 #4
0
        public async Task <bool> UpdateOrderPaymentAsync(UpdatePaymentDto paymentDto)
        {
            using var uow = _unitOfWorkManager.Begin();

            var invoice = new Invoice
            {
                InvoiceDate = DateTime.Now,
                OrderId     = paymentDto.OrderId,
                PaidAmount  = paymentDto.PaidAmount
            };

            var order = _repository.Get(paymentDto.OrderId);

            await _repository.EnsureCollectionLoadedAsync(order, o => o.OrderDetails);

            var dueAmount = order.OrderDetails.Sum(s => s.SubTotal) - (order.AdvancePaid.HasValue ? order.AdvancePaid.Value : 0);

            if (dueAmount < paymentDto.PaidAmount)
            {
                throw new Exception("amount exceed");
            }
            else if (paymentDto.PaidAmount == dueAmount)
            {
                order.PaymentStatus = PaymentStatus.Paid;
            }
            else
            {
                order.PaymentStatus = PaymentStatus.PartialPaid;
            }

            order.OrderStatus = OrderStatus.Delivered;

            await _repository.UpdateAsync(order);

            await _invoiceRepository.InsertAsync(invoice);

            await uow.CompleteAsync();

            return(true);
        }
コード例 #5
0
 public IActionResult Put(int id, [FromBody] UpdatePaymentDto model) =>
 _mapper.Map <PaymentUpdateModel>(model)
 .Map(x => _commandRepo.Update(id, x))
 .Map(x => AllOk(new { updated = x }))
 .Reduce(_ => NotFound(), error => error is RecordNotFound)
 .Reduce(_ => InternalServerError(), x => _logger.LogError(x.ToString()));