public async Task <IActionResult> PutSportsTb([FromRoute] int id, [FromBody] SportsTb sportsTb) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != sportsTb.SportsId) { return(BadRequest()); } _context.Entry(sportsTb).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SportsTbExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PostSportsTb([FromBody] SportsTb sportsTb) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.SportsTb.Add(sportsTb); try { await _context.SaveChangesAsync(); } catch (DbUpdateException) { if (SportsTbExists(sportsTb.SportsId)) { return(new StatusCodeResult(StatusCodes.Status409Conflict)); } else { throw; } } return(CreatedAtAction("GetSportsTb", new { id = sportsTb.SportsId }, sportsTb)); }