예제 #1
0
 public IHttpActionResult Post(Role role)
 {
     using (var fullStackContext = new FullStackContext())
     {
         fullStackContext.Roles.Add(role);
         fullStackContext.SaveChanges();
         return Ok(role);
     }
 }
예제 #2
0
 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();
         }
     }
 }