예제 #1
0
        public HttpResponseMessage Get()
        {
            //throw new Exception("This is throwed manually.");
            var user = UserInfoMethod.CurrentUser();

            if (user.Role == "Admin")
            {
                var categories = db.Categories.ToList();
                if (categories != null)
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, categories));
                }
                else
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Categories are not found."));
                }
            }
            else
            {
                return(Request.CreateErrorResponse(HttpStatusCode.Unauthorized, "Categories can be listed by Admin!"));
            }

            //Request.CreateResponse(HttpStatusCode.Accepted);
        }
예제 #2
0
 //Oturum açan kişinin bilgileri alınacak
 public HttpResponseMessage Get()
 {
     return(Request.CreateResponse(HttpStatusCode.OK, UserInfoMethod.CurrentUser()));
 }
예제 #3
0
 public IHttpActionResult Get()
 {
     return(Ok(UserInfoMethod.CurrentUser()));
 }