Exemplo n.º 1
0
        public IHttpActionResult GetControlByID(int id)
        {
            MesRoles role = new MesRoles {
                role_id = id
            };

            role = roleRes.Get(role);
            if (role == null)
            {
                return(NotFound());
            }
            return(Ok(role));
        }
Exemplo n.º 2
0
 public IHttpActionResult PutControl(MesRoles role)
 {
     try
     {
         if (!ModelState.IsValid)
         {
             return(BadRequest(ModelState));
         }
         if (!roleRes.Update(role))
         {
             return(NotFound());
         }
         return(Ok(role));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
Exemplo n.º 3
0
 public IHttpActionResult PostControl(MesRoles role)
 {
     try
     {
         if (!ModelState.IsValid)
         {
             return(BadRequest(ModelState));
         }
         role = roleRes.Create(role);
         string apiname = WebApiConfig.DEFAULT_ROUTE_NAME;
         var    respone = this.Request.CreateResponse <MesRoles>(HttpStatusCode.Created, role);
         string uri     = Url.Link(apiname, new { id = role.role_id });
         respone.Headers.Location = new Uri(uri);
         return(Ok(role));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
Exemplo n.º 4
0
 public IHttpActionResult DeleteControl(int id)
 {
     try
     {
         if (!ModelState.IsValid)
         {
             return(BadRequest(ModelState));
         }
         MesRoles role = new MesRoles {
             role_id = id
         };
         role = roleRes.Get(role);
         if (role == null)
         {
             throw new HttpResponseException(HttpStatusCode.NotFound);
         }
         roleRes.Remove(id);
         return(Ok("Deleted role!"));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }