コード例 #1
0
ファイル: UsersController.cs プロジェクト: npelle/seia-gpv
        public IHttpActionResult GetUser(int id)
        {
            var userService = new UserService();
            var postService = new PostService();
            var user        = userService.GetUserById(new GetUserByIdRequest()
            {
                UserId = id
            }).User;

            if (user == null)
            {
                return(NotFound());
            }

            var result = TheModelFactory.CreateUserModel(user);

            var posts = postService.SearchPostsByUserId(new SearchPostsByUserIdRequest {
                UserId = id
            }).Posts.OrderByDescending(x => x.EffectDate).ToList();

            result.Post = new List <PostsForUserDetail>();

            foreach (var post in posts)
            {
                var postResult = TheModelFactory.CreatePostsForUserDetail(post);

                result.Post.Add(postResult);
            }

            return(Ok(result));
        }