Beispiel #1
0
        public IActionResult Create(CreatePostViewModel model)
        {
            if (!ModelState.IsValid)
                return HttpBadRequest();

            var postId = _postRepository.AddPost(model);

            return RedirectToRoute("thread", new { threadId = postId});
        }
Beispiel #2
0
        public Guid AddPost(CreatePostViewModel model)
        {
            var post = new Post
            {
                AuthorName = model.AuthorName,
                Title = model.Title,
                Url = model.Url
            };

            _context.Posts.Add(post);
            _context.SaveChanges();

            return post.Id;
        }