Exemplo n.º 1
0
        public async Task <ActionResult <Wallet> > DeleteWallet(DeleteWalletCommand command)
        {
            var wallet = await _context.Wallets.FindAsync(command.WalletId);

            if (wallet == null)
            {
                return(null);
            }
            wallet.Deleted = true;
            _context.Entry(wallet).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!WalletExists(command.WalletId))
                {
                    return(null);
                }
                else
                {
                    throw;
                }
            }

            return(wallet);
        }
        public async Task <IActionResult> DeleteWallet(int walletId)
        {
            var deleteWalletCommand = new DeleteWalletCommand(walletId);
            var result = await mediator.Send(deleteWalletCommand);

            return(StatusCode((int)result.Code, result.Value));
        }
Exemplo n.º 3
0
        public ResultCommand Handle(DeleteWalletCommand command)
        {
            var result = new ResultCommand();

            var wallet = _repository.GetById(command.Id);

            wallet.Delete();
            result.AddNotifications(wallet);

            if (result.Valid)
            {
                _repository.Update(wallet);
            }
            return(result);
        }
Exemplo n.º 4
0
 public async Task <ActionResult <DeleteWalletCommandResponse> > Delete(DeleteWalletCommand request, CancellationToken cancellationToken = default(CancellationToken))
 {
     return(await Send(request, cancellationToken));
 }