public async Task <IActionResult> PutTbMDeptInput([FromRoute] short id, [FromBody] TbMDeptInput tbMDeptInput) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != tbMDeptInput.YearActive) { return(BadRequest()); } _context.Entry(tbMDeptInput).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TbMDeptInputExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PostTbMDeptInput([FromBody] TbMDeptInput tbMDeptInput) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.TbMDeptInput.Add(tbMDeptInput); try { await _context.SaveChangesAsync(); } catch (DbUpdateException) { if (TbMDeptInputExists(tbMDeptInput.YearActive)) { return(new StatusCodeResult(StatusCodes.Status409Conflict)); } else { throw; } } return(CreatedAtAction("GetTbMDeptInput", new { id = tbMDeptInput.YearActive }, tbMDeptInput)); }
public async Task <IActionResult> DeleteTbMDeptInput([FromBody] TbMDeptInput controlDelete) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var tbMDeptInput = await _context.TbMDeptInput.SingleOrDefaultAsync(e => e.YearActive == controlDelete.YearActive && e.DeptInpId == controlDelete.DeptInpId); if (tbMDeptInput == null) { return(NotFound()); } _context.TbMDeptInput.Remove(tbMDeptInput); await _context.SaveChangesAsync(); return(Ok(tbMDeptInput)); }