Exemplo n.º 1
0
 public ActionResult <GenericCommandResult> Delete(
     [FromBody] DeleteDespesaCommand command
     )
 {
     //command.User = User.Claims.FirstOrDefault(x => x.Type == "user_id")?.Value;
     command.ChaveDeAcesso = "xpto123t";
     return(Ok((GenericCommandResult)_handler.Handle(command)));
 }
Exemplo n.º 2
0
        public ICommandResult Handle(DeleteDespesaCommand command)
        {
            command.Validate();

            if (command.Invalid)
            {
                return(new GenericCommandResult(false, "Ops, Alguma inconsistencia nos dados", command.Notifications));
            }

            var despesa = _repository.GetById(command.Id, command.ChaveDeAcesso);

            _repository.Delete(despesa.Id);

            return(new GenericCommandResult(true, $"A despesa {despesa.Nome.ToString()} foi excluida com Sucesso!", despesa));
        }