public async Task<IHttpActionResult> PutRole(int id, Role role) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != role.Id) { return BadRequest(); } db.Entry(role).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RoleExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> PostRole(Role role) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Roles.Add(role); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = role.Id }, role); }