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)); }
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); }
public async Task <ActionResult <DeleteWalletCommandResponse> > Delete(DeleteWalletCommand request, CancellationToken cancellationToken = default(CancellationToken)) { return(await Send(request, cancellationToken)); }