コード例 #1
0
        public HttpResponseMessage GetUser(int id, [FromUri] string token = "")
        {
            if (auth.ValidateToken(token) == null)
            {
                return(new HttpResponseMessage(HttpStatusCode.Unauthorized));
            }

            User user = db.GetUserById(id);

            if (user == null)
            {
                return(new HttpResponseMessage(HttpStatusCode.NotFound));
            }
            else
            {
                User noPassword = new User(user);
                noPassword.Password = "";
                return(Request.CreateResponse(HttpStatusCode.OK, noPassword));
            }
        }