public async Task <IActionResult> Put(DiscTurma Request) { try { if (!ModelState.IsValid) { return(BadRequest(Request)); } var discturma = await _repo.GetDiscTurmaById(Request.Id); if (discturma == null) { return(NotFound(MSG.NaoExisteDiscTurma)); } _repo.Update(Request); if (await _repo.SaveChangesAsync()) { return(Created($"/api/[controler]/DiscTurma{Request.Id}", Request)); } } catch (Exception) { return(this.StatusCode(StatusCodes.Status501NotImplemented, MSG.BancoDadosFalhou)); } return(BadRequest()); }
public async Task <IActionResult> Post(DiscTurma Request) { try { if (!ModelState.IsValid) { return(BadRequest(Request)); } _repo.Add(Request); if (await _repo.SaveChangesAsync()) { return(Created($"/api/[controler]/DiscTurma{Request.Id}", Request)); } } catch (Exception) { return(this.StatusCode(StatusCodes.Status501NotImplemented, MSG.BancoDadosFalhou)); } return(BadRequest()); }