コード例 #1
0
        public async Task <CommandResponse> Handle(CriarEventoCommand command, CancellationToken cancellationToken)
        {
            var qtdPessoas = new QuantidadePessoas(command.QtdPessoas);
            var email      = new Email(command.Email);

            var evento = new Evento(null,
                                    command.Local,
                                    Convert.ToDateTime(command.DataEvento),
                                    command.Tema,
                                    qtdPessoas,
                                    command.ImagemUrl,
                                    command.Telefone,
                                    email,
                                    command.Lotes,
                                    command.RedesSociais);

            if (evento.Valid)
            {
                await _repository.Adicionar(evento);

                if (await _repository.Commitar())
                {
                    Response.Success = true;
                    Response.Messages.Add("Evento criado com sucesso!");
                    return(Response);
                }
            }
            Response.Success = false;
            Response.Messages.AddRange(evento.Notifications.Select(x => x.Message));
            return(Response);
        }
コード例 #2
0
 public async Task <ObjectResult> InserirEvento([FromBody] CriarEventoCommand command)
 {
     return(await BaseResult(command));
 }