Ejemplo n.º 1
0
        public async Task <ICommandResult> Handle(EditaEventoCommand command)
        {
            try
            {
                var evento = await _eventoRepository.GetEventoByIdentifier(command.identifyer);

                command.Validate();
                if (command.Valid)
                {
                    evento.EditaEvento(command.Local, DateTime.Parse(command.DataEvento), command.Tema, command.QtdPessoas, command.ImgUrl, command.Telefone, command.Email);
                    _eventoRepository.Edit(evento);
                    return(new CriaEventoCommandResult(true, "Editado", new
                    {
                        Id = evento.identifyer,
                        Tema = evento
                    }));
                }
                return(new CriaEventoCommandResult(false, "Erro", new
                {
                    Erros = command.Notifications
                }));
            }
            catch (Exception ex)
            {
                return(new CriaEventoCommandResult(false, "Erro", new
                {
                    mensagem = ex.Message
                }));
            }
        }
Ejemplo n.º 2
0
 public async Task <IActionResult> Put([FromBody] EditaEventoCommand command)
 {
     try
     {
         return(Ok(_eventoHandler.Handle(command)));
     }
     catch (Exception ex)
     {
         return(this.StatusCode(StatusCodes.Status500InternalServerError, ex.Message));
     }
 }