public IHttpActionResult PostGroupType(GroupType groupType) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.GroupTypes.Add(groupType); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = groupType.Id }, groupType); }
public IHttpActionResult PutGroupType(int id, GroupType groupType) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != groupType.Id) { return BadRequest(); } db.Entry(groupType).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!GroupTypeExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }