Exemple #1
0
        public void Remove(DeleteClienteCommand command)
        {
            var cliente = clienteRepository.GetById(command.Id);

            if (cliente == null)
            {
                throw new Exception("Cliente não encontrado.");
            }

            clienteRepository.Remove(cliente);
        }
Exemple #2
0
        public async Task <ActionResult> ExcluirCliente(Guid id)
        {
            var command = new DeleteClienteCommand {
                Id = id
            };
            await _bus.Send(command);

            if (!_notificationContext.HasErrorNotifications)
            {
                return(NoContent());
            }
            var notifications = _notificationContext.GetErrorNotifications();

            return(BadRequest(notifications));
        }
        public async Task <bool> Handle(DeleteClienteCommand request, CancellationToken cancellationToken)
        {
            if (request == null)
            {
                return(false);
            }

            var cliente = new Cliente(request.id);
            await _repository.Delete(cliente.id);

            await _repository.Save();

            await _mediator.Publish(new ClienteDeleteEvent(cliente.id), cancellationToken);

            return(await Task.FromResult(true));
        }
Exemple #4
0
        public IActionResult Delete(int id)
        {
            try
            {
                var command = new DeleteClienteCommand {
                    Id = id
                };

                clienteApplicationService.Remove(command);

                return(Ok(new { Message = "Cliente excluido com sucesso." }));
            }
            catch (Exception e)
            {
                return(StatusCode(500, e.Message));
            }
        }
Exemple #5
0
        public async Task <IActionResult> Delete(DeleteClienteCommand obj)
        {
            var x = await _mediator.Send(obj);

            return(Ok(x));
        }