Пример #1
0
        public async Task <ActionResult> CreatePost(string body)
        {
            long userId  = Convert.ToInt64(HttpContext.Session.GetString("userId"));
            Post post    = new Post();
            Post newPost = post.CreatePost(body, userId);

            _context.Post.Add(newPost);
            await _context.SaveChangesAsync();

            return(Redirect("/"));
        }
        public async Task <ActionResult <Post> > PostPost(Post post)
        {
            _context.AcebookPosts.Add(post);
            await _context.SaveChangesAsync();

            return(CreatedAtAction(nameof(GetById), new { id = post.Id }, post));
        }