예제 #1
0
        public async Task <IActionResult> DeletePaymentInvoice(int paymentInvoiceId, DeletePaymentInvoiceDto request)
        {
            var response = await Executor.GetHandler <DeletePaymentInvoiceCommand>().Process(h =>
                                                                                             h.ExecuteAsync(paymentInvoiceId, request));

            return(Ok(response));
        }
예제 #2
0
        public async Task <DeletePaymentInvoiceResponseDto> ExecuteAsync(int paymentInvoiceId, DeletePaymentInvoiceDto requestDto)
        {
            var response = new DeletePaymentInvoiceResponseDto();

            response.Success = false;
            response.Message = "Невозможно удалить выставленную оплату, т.к. имеются зачтённые суммы.";
            var systemUser = _executor.GetQuery <GetUserByXinQuery>().Process(q => q.Execute(UserConstants.SystemUserXin));

            var paymentInvoiceItem = await _executor.GetHandler <GetPaymentInvoiceByIdQuery>().Process(h =>
                                                                                                       h.ExecuteAsync(paymentInvoiceId));

            if (paymentInvoiceItem.CreateUserId != systemUser.Id)
            {
                if (!paymentInvoiceItem.PaymentUses.Any())
                {
                    _executor.GetCommand <DeletePhisicallyPaymentInvoiceCommand>().Process(c => c.Execute(paymentInvoiceItem));
                    response.Success = true;
                    response.Message = "Платеж был удален физически.";
                }
            }
            else
            {
                if (!paymentInvoiceItem.PaymentUses.Any())
                {
                    paymentInvoiceItem.IsDeleted   = true;
                    paymentInvoiceItem.DeletedDate = DateTimeOffset.Now;
                    _executor.GetCommand <UpdatePaymentInvoiceCommand>().Process(c => c.Execute(paymentInvoiceItem));
                    response.Success = true;
                    response.Message = "Платеж был удален.";
                }
            }
            return(response);
        }