예제 #1
0
        public GenericCommandResult Delete(
            long id,
            [FromServices] LeilaoHandler handler
            )
        {
            var command = new DeleteLeilaoCommand();

            command.User = User.Claims.FirstOrDefault(x => x.Type == "user_id")?.Value;
            command.Id   = id;
            return((GenericCommandResult)handler.Handle(command));
        }
예제 #2
0
        public ICommandResult Handle(DeleteLeilaoCommand command)
        {
            // Fail Fast Validation(o comando chegou falho ele já barra e avisa)
            command.Validate();
            if (command.Invalid)
            {
                return(new GenericCommandResult(false, "Algo deu errado ao excluir!", command.Notifications));
            }

            var leilao = _repository.GetById(command.Id, command.User);

            _repository.Delete(leilao);

            return(new GenericCommandResult(true, "Leilão excluído!", leilao));
        }