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); }
//Oturum açan kişinin bilgileri alınacak public HttpResponseMessage Get() { return(Request.CreateResponse(HttpStatusCode.OK, UserInfoMethod.CurrentUser())); }
public IHttpActionResult Get() { return(Ok(UserInfoMethod.CurrentUser())); }