Exemplo n.º 1
0
        public ActionResult <Post> PostPost(Post post)
        {
            _postData.Add(post);
            _postData.Commit();

            return(CreatedAtAction("GetPost", new { id = post.Id }, post));
        }
Exemplo n.º 2
0
        public IActionResult OnPost(int Id)
        {
            Post.UserId = Id;
            var p = postdata.Add(Post);

            postdata.commit();
            return(RedirectToPage("./Home", new { Id }));
        }
Exemplo n.º 3
0
        public ActionResult CreatePost(Post post)
        {
            if (ModelState.IsValid)
            {
                post.PostTime = DateTime.Now;
                postData.Add(post);
                return(RedirectToAction("PostDetails", new { id = post.ID }));
            }

            return(View());
        }
Exemplo n.º 4
0
        public ActionResult Create([Bind(Include = "PostId,Text,PostRating")] Post post, int id)
        {
            post.DateCreated = DateTime.Now;
            post.DateEdited  = DateTime.Now;
            var movie = _db.GetMovie(id);

            post.MovieTitle = movie.Title;
            if (ModelState.IsValid)
            {
                _db.Add(post);
                return(RedirectToAction("Details", new { id = post.PostId }));
            }
            var movies = _db.GetAllMovies();

            ViewBag.PostId = new SelectList(movies, "MovieId", "Title", post.PostId);
            return(View(post));
        }
Exemplo n.º 5
0
        public IActionResult Create(PostEditViewModel post)
        {
            if (ModelState.IsValid)
            {
                var newPost = new Post();
                newPost.Title     = post.Title;
                newPost.Type      = post.Type;
                newPost.Content   = post.Content;
                newPost.Upvotes   = 1;
                newPost.Downvotes = 0;
                newPost.Poster    = _userManager.GetUserAsync(User).Result;
                newPost           = _postData.Add(newPost);
                _postData.Commit();

                return(RedirectToAction("Details", new { id = newPost.Id }));
            }
            return(View());
        }
Exemplo n.º 6
0
        public IActionResult Create(PostEditModel model)
        {
            if (ModelState.IsValid)
            {
                var newPost = new Post
                {
                    TitleOfPost       = model.TitleOfPost,
                    DescriptionOfPost = model.DescriptionOfPost,
                    Tags = model.Tags
                };


                newPost = _postData.Add(newPost);

                return(RedirectToAction(nameof(Details), new { id = newPost.Id }));
            }
            else
            {
                return(View());
            }
        }
Exemplo n.º 7
0
 public void Create([FromBody] Post post)
 {
     post.UserId = AuthorizationServerProvider.getUserId();
     source.Add(post);
 }