// PUT api/Groups/5 public async Task<IHttpActionResult> PutGroup(int id, Group group) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != group.GroupId) { return BadRequest(); } db.Entry(group).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!GroupExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> PostGroup(Group group) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Groups.Add(group); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = group.GroupId }, group); }