public void SavePostTestContext() { Post p4 = new Post(4, "Post04", "test", 1, DateTime.Now, "None", "None"); var result = postRepo.CreateNewPost(p4); var TotalPosts = postRepo.RetrieveAllPosts(); Assert.IsTrue(TotalPosts.Count > 3); }
public IActionResult Add(PostViewModel model, string uploadedImage) { model.PostImage = uploadedImage; Post p = new Post(-1, model.Title, model.Content, model.Status, DateTime.Now, model.PostImage, model.Excerpt); if (postRep.CreateNewPost(p) == true) { return(RedirectToAction("Overview", "Post")); } else { return(RedirectToAction("Dashboard", "Home")); } }
static void CreateNewPost(Thread thread) { Console.WriteLine("Write your post text: "); string tmpPostText = Console.ReadLine(); tmpPostText = Helper.ReturnOkayString(tmpPostText, 4, 100); var tmpPost = new Post(); tmpPost.post_text = tmpPostText; tmpPost.user_id = CurrentUser.user_id; tmpPost.thread_id = thread.thread_id; PostRepository.CreateNewPost(tmpPost); Console.WriteLine("New post created."); Helper.PressAnyKeyToContinue(); }