public async Task<IActionResult> PutAgroup(int id, Agroup agroup) { if (id != agroup.Pgrp) { return BadRequest(); } _context.Entry(agroup).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AgroupExists(id)) { return NotFound(); } else { throw; } } return NoContent(); }
public async Task<ActionResult<Agroup>> PostAgroup(Agroup agroup) { _context.Agroups.Add(agroup); try { await _context.SaveChangesAsync(); } catch (DbUpdateException) { if (AgroupExists(agroup.Pgrp)) { return Conflict(); } else { throw; } } return CreatedAtAction("GetAgroup", new { id = agroup.Pgrp }, agroup); }