public IActionResult Create(CreatePostViewModel model) { if (!ModelState.IsValid) return HttpBadRequest(); var postId = _postRepository.AddPost(model); return RedirectToRoute("thread", new { threadId = postId}); }
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; }