public async Task <IActionResult> OnPostDeleteAsync(int id, DeleteCusotmerCommand command)
        {
            command.Id = id;
            var isDeleted = await _mediator.Send(command);

            return(RedirectToPage());
        }
Exemple #2
0
        public Task <bool> Handle(DeleteCusotmerCommand request, CancellationToken cancellationToken)
        {
            var customer = _context.Customers.Find(request.Id);

            if (customer != null)
            {
                _context.Customers.Remove(customer);
                _context.SaveChangesAsync();
                return(Task.FromResult(true));
            }

            return(Task.FromResult(false));
        }