示例#1
0
 public JsonResult Get([FromRoute] int?id)
 {
     if (AuthRepo.IsAuthenticated(Role.Admin))
     {
         if (id.HasValue)
         {
             var user = AppRepo.GetUserModelById(id.Value);
             if (user != null)
             {
                 return(Json(user));
             }
             else
             {
                 Response.StatusCode = 404;
             }
             return(Json(new { Msg = "User doesn't exists" }));
         }
     }
     Response.StatusCode = 401;
     return(Json(new { Msg = "You are not admin" }));
 }