public IHttpActionResult PostGroup(Group group) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Groups.Add(group); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = group.Id }, group); }
public IHttpActionResult PutGroup(int id, Group group) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != group.Id) { return BadRequest(); } db.Entry(group).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!GroupExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }