Пример #1
0
        public IHttpActionResult UpdateRole(int id, Role role)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                RoleServices.UpdateRoleById(id, role);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!RoleExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Пример #2
0
 public IHttpActionResult AddRole(Role role)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest(ModelState));
     }
     RoleServices.AddRole(role);
     return(Ok(role));
 }
Пример #3
0
        public IHttpActionResult DeleteRoleById(int id)
        {
            Role role = RoleServices.DeleteRole(id);

            if (role == null)
            {
                return(NotFound());
            }
            return(Ok(role));
        }