Esempio n. 1
0
        public async Task <IActionResult> DeleteById(int id)
        {
            var notif  = new DeletePaymentCommand(id);
            var result = await _mediatr.Send(notif);

            return(result != null ? (IActionResult)Ok(new { Message = "success" }) : NotFound(new { Message = "Payment not found" }));
        }
Esempio n. 2
0
        public async Task <IActionResult> Delete(int id)
        {
            var command = new DeletePaymentCommand(id);
            var result  = await _mediatr.Send(command);

            return(command != null ? (IActionResult)Ok(new { Message = "deleted" }) : NotFound(new { Message = "not found" }));
        }
Esempio n. 3
0
        public async Task <ActionResult <bool> > DeletePayment(int id)
        {
            DeletePaymentCommand command = new DeletePaymentCommand();

            command.Id = id;
            return(await Send(command));
        }
Esempio n. 4
0
        public async Task <BaseDto <Payment_Output> > Handle(DeletePaymentCommand request, CancellationToken cancellationToken)
        {
            try
            {
                var data = await _context.payments.FindAsync(request.id);

                _context.payments.Remove(data);
                await _context.SaveChangesAsync(cancellationToken);

                return(new BaseDto <Payment_Output>
                {
                    message = "Success Delete Payment Data",
                    success = true,
                    data = new Payment_Output
                    {
                        order_id = data.order_id,
                        transaction_id = data.transaction_id,
                        payment_type = data.payment_type,
                        gross_amount = Convert.ToInt64(data.gross_amount),
                        transaction_time = data.transaction_time,
                        transaction_status = data.transaction_status
                    }
                });
            }
            catch (Exception)
            {
                return(new BaseDto <Payment_Output>
                {
                    message = "Failed Delete Payment Data",
                    success = false,
                    data = null
                });
            }
        }
        public void ShouldRequireValidPaymentId()
        {
            var command = new DeletePaymentCommand {
                Id = 99
            };

            FluentActions.Invoking(() =>
                                   SendAsync(command)).Should().Throw <NotFoundException>();
        }
Esempio n. 6
0
        public void Handle_GivenInvalidId_ThrowsException()
        {
            var command = new DeletePaymentCommand
            {
                Id = 99
            };

            var sut = new DeletePaymentCommandHandler(_repository);

            Assert.ThrowsAsync <NotFoundException>(() =>
                                                   sut.Handle(command, CancellationToken.None));
        }
Esempio n. 7
0
        public async Task Handle_GivenValidId_ShouldRemovePersistedPayment()
        {
            var command = new DeletePaymentCommand
            {
                Id = 1
            };

            var sut = new DeletePaymentCommandHandler(_repository);

            await sut.Handle(command, CancellationToken.None);

            var entity = await _repository.GetByIdAsync(command.Id).ConfigureAwait(false);

            entity.Should().BeNull();
        }
Esempio n. 8
0
        public ActionResult Delete(DeletePaymentCommand command)
        {
            var result = _commandBus.Send(command);

            return(JsonMessage(result));
        }