public async Task <IActionResult> PutTbMAccidentDetail([FromRoute] short id, [FromBody] TbMAccidentDetail tbMAccidentDetail) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.Entry(tbMAccidentDetail).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TbMAccidentDetailExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PostTbMAccidentDetail([FromBody] TbMAccidentDetail tbMAccidentDetail) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.TbMAccidentDetail.Add(tbMAccidentDetail); try { await _context.SaveChangesAsync(); } catch (DbUpdateException) { if (TbMAccidentDetailExists(tbMAccidentDetail.YearActive)) { return(new StatusCodeResult(StatusCodes.Status409Conflict)); } else { throw; } } return(CreatedAtAction("GetTbMAccidentDetail", new { id = tbMAccidentDetail.YearActive }, tbMAccidentDetail)); }
public async Task <IActionResult> DeleteTbMAccidentDetail([FromBody] TbMAccidentDetail controlDelete) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var tbMAccidentDetail = await _context.TbMAccidentDetail.SingleOrDefaultAsync(e => e.YearActive == controlDelete.YearActive && e.AccidentId == controlDelete.AccidentId); if (tbMAccidentDetail == null) { return(NotFound()); } _context.TbMAccidentDetail.Remove(tbMAccidentDetail); await _context.SaveChangesAsync(); return(Ok(tbMAccidentDetail)); }