Example #1
0
        public async Task <IActionResult> Post(Evento model)
        {
            /*
             * {
             * "Local": "TEste",
             * "DataEvento": "#1/4/2019 8:30:00#",
             * "Tema": "Anglar + .NET Core",
             * "QtdPessoas": 400,
             * "ImagemURL": "teste.jgb",
             * "Telefone": "123123",
             * "Email": "*****@*****.**",
             * "Lote": "2",
             * "Lotes": []
             * "RedesSociais": [],
             * "PalestrantesEventos": []
             * }
             */
            try
            {
                _repo.Add(model);

                if (await _repo.SaveChangesAsync())
                {
                    return(Created($"/api/evento/{model.Id}", model));
                }
            }
            catch (System.Exception)
            {
                return(this.StatusCode(StatusCodes.Status500InternalServerError, "Banco de dados falhou"));
            }

            return(BadRequest());
        }
Example #2
0
 public async Task <IActionResult> Post(Palestrante model)
 {
     try
     {
         _repo.Add(model);
         if (await _repo.SaveChangesAsync())
         {
             return(Created($"api/palestrante/{model.Id}", model));
         }
     }
     catch (System.Exception)
     {
         return(this.StatusCode(StatusCodes.Status500InternalServerError, "Banco de dados falhou"));
     }
     return(BadRequest());
 }
 public async Task <IActionResult> Post(EventoDto model)
 {
     try
     {
         var evento = _mapper.Map <Evento>(model);
         _repo.Add(evento);
         if (await _repo.SaveChangesAsync())
         {
             return(Created($"api/evento/{model.Id}", _mapper.Map <EventoDto>(evento)));
         }
     }
     catch (System.Exception ex)
     {
         return(this.StatusCode(StatusCodes.Status500InternalServerError, $"Banco de dados falhou {ex.Message}"));
     }
     return(BadRequest());
 }