public IEnumerable <PostItem> List() { PostItem postItem0 = new PostItem() { value = "List 0" }; PostItem postItem1 = new PostItem() { value = "List 1" }; return(new PostItem[] { postItem0, postItem1 }); }
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]); }
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]); }
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 })); }
public async Task AddPost(PostItem post) { _postContext.PostsItems.Add(post); await _postContext.SaveChangesAsync(); }