Exemple #1
0
        public IEnumerable <PostItem> List()
        {
            PostItem postItem0 = new PostItem()
            {
                value = "List 0"
            };
            PostItem postItem1 = new PostItem()
            {
                value = "List 1"
            };

            return(new PostItem[] { postItem0, postItem1 });
        }
Exemple #2
0
        public PostItem Get(int id)
        {
            PostItem postItem0 = new PostItem()
            {
                value = "Get 0"
            };
            PostItem postItem1 = new PostItem()
            {
                value = "Get 1"
            };

            return(new PostItem[] { postItem0, postItem1 }[id]);
        }
Exemple #3
0
        public PostItem GetCustom(int id2)
        {
            PostItem postItem0 = new PostItem()
            {
                value = "GetCustom 0"
            };
            PostItem postItem1 = new PostItem()
            {
                value = "GetCustom 1"
            };

            return(new PostItem[] { postItem0, postItem1 }[id2]);
        }
Exemple #4
0
        public async Task <IActionResult> PostPostItem([FromRoute] int id, [BindRequired][FromBody] PostItem post)
        {
            User user;

            try
            {
                user = await GetUserById(id);
            }
            catch (InvalidOperationException)
            {
                return(NotFound("Specified user could not be found"));
            }

            post.userId = id;
            await AddPost(post);

            return(Ok
                       (new
            {
                content = post.content
            }));
        }
Exemple #5
0
 public async Task AddPost(PostItem post)
 {
     _postContext.PostsItems.Add(post);
     await _postContext.SaveChangesAsync();
 }