예제 #1
0
 public GenericCommandResult Update(
     [FromBody] UpdateLeilaoCommand command,
     [FromServices] LeilaoHandler handler
     )
 {
     command.User = User.Claims.FirstOrDefault(x => x.Type == "user_id")?.Value;
     return((GenericCommandResult)handler.Handle(command));
 }
예제 #2
0
        public ICommandResult Handle(UpdateLeilaoCommand 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 editar!", command.Notifications));
            }

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

            leilao.UpdateLeilao
            (
                command.nome_leilao,
                command.valor_inicial,
                command.item_usado,
                command.data_inicio,
                command.data_fim
            );

            _repository.Update(leilao);

            return(new GenericCommandResult(true, "Leilão salvo!", leilao));
        }