コード例 #1
0
        public async Task <IActionResult> Put(int EventoId, Evento model)
        {
            try
            {
                var evento = await _repo.GetEventoAsyncById(EventoId, false);

                if (evento == null)
                {
                    return(NotFound());
                }

                _repo.Update(model);

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

            return(BadRequest());
        }
コード例 #2
0
        public async Task <IActionResult> Put(int id, EventoDto model)

        {
            try
            {
                var evento = await _repo.getAllEventoAsyncByid(id, false);


                if (evento == null)
                {
                    return(NotFound());
                }
                _mapper.Map(model, evento);

                _repo.Update(evento);

                if (await _repo.SaveChangesAsync())
                {
                    return(Created($"/api/eventos/{model.id}", _mapper.Map <EventoDto>(evento)));
                }
            }
            catch (System.Exception ex)
            {
                return(this.StatusCode(StatusCodes.Status500InternalServerError, $"Falha ao conectar com a base de dados, tente novamente mais tarde {ex.Message}"));
            }
            return(BadRequest());
        }
コード例 #3
0
        public async Task <IActionResult> Put(int PalestranteId, Palestrante model)
        {
            try
            {
                var palestrante = await _palestrante.GetPalestranteAsync(PalestranteId, false);

                if (palestrante == null)
                {
                    return(NotFound());
                }

                _palestrante.Update(model);

                if (await _palestrante.SaveChangesAsync())
                {
                    return(Created($"/api/palestrante/{model.Id}", model));
                }
            }
            catch (System.Exception)
            {
                return(this.StatusCode(StatusCodes.Status500InternalServerError, "Banco Dados Falhou"));
            }

            return(BadRequest());
        }