Пример #1
0
        public async Task <IActionResult> Put(int Id, EasyBalad model)
        {
            try
            {
                var evento = await _repo.GetEasyAsyncById(Id);

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

                _repo.Update(evento);

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

            return(BadRequest());
        }
Пример #2
0
        public async Task <IActionResult> Post(EasyBalad model)
        {
            try
            {
                _repo.Add(model);

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

            return(BadRequest());
        }