public async Task<IHttpActionResult> PutUserRole(int id, UserRole userRole) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != userRole.UserRoleId) { return BadRequest(); } db.Entry(userRole).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserRoleExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> PostUserRole(UserRole userRole) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.UserRoles.Add(userRole); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = userRole.UserRoleId }, userRole); }