Exemplo n.º 1
0
        public HttpResponseMessage Delete(RoleModel role)
        {
            try
            {
                MembershipUtils.DeleteRole(role.Name);
            }
            catch(Exception ex)
            {
                return Request.CreateResponse(HttpStatusCode.BadRequest, new { Message = ex.Message });
            }

            return Request.CreateResponse(HttpStatusCode.OK);
        }
Exemplo n.º 2
0
        public HttpResponseMessage Post(RoleModel role)
        {
            var newRole = role.Name;

            try
            {
                if (MembershipUtils.IsRoleExists(newRole)) throw new Exception("Роль существует");
                MembershipUtils.CreateRole(newRole);
            }
            catch (Exception ex)
            {
                return Request.CreateResponse(HttpStatusCode.BadRequest, new { Message = ex.Message });
            }

            return Request.CreateResponse(HttpStatusCode.OK);
        }