public IHttpActionResult Post(Role role) { using (var fullStackContext = new FullStackContext()) { fullStackContext.Roles.Add(role); fullStackContext.SaveChanges(); return Ok(role); } }
public IHttpActionResult Put(int id, Role role) { using (var fullStackContext = new FullStackContext()) { try { var dbRole = fullStackContext.Roles.Single(r => r.RoleId == id); dbRole.RoleName = role.RoleName; fullStackContext.SaveChanges(); return Ok(dbRole); } catch (InvalidOperationException) { return NotFound(); } catch (Exception) { return Conflict(); } } }