public PartialViewResult LastOnesFromFolloweds() { PostRepo pr = new PostRepo(); Random rnd = new Random(); User current = Session["user"] as User; List <Post> posts = pr.GetFollowedPosts(current.UserID, 2); List <Post> shortPosts = new List <Post>(); if (posts.Count > 12) { for (int i = 0; i < 12;) { Post p = posts[rnd.Next(0, posts.Count)]; if (!shortPosts.Contains(p)) { shortPosts.Add(p); i++; } } } else { shortPosts = posts; } return(PartialView("~/Views/Shared/_PostShowcasePartial.cshtml", shortPosts)); }
public void CanFindPreviousPublishedPost(int postid, int x) { PostRepo repo = new PostRepo(); int prev = repo.FindPreviousPublishedPost(postid); Assert.AreEqual(x, prev); }
public ActionResult EditPost(int id) { PostRepo reap = new PostRepo(); var model = reap.GetPostById(id); return(View(model)); }
public void CanloadCommentsbyID(int postID, int x) { PostRepo repo = new PostRepo(); List <Comment> cmts = repo.GetCommentsbyPost(postID); Assert.AreEqual(x, cmts.Count()); }
public void CanLoadCategoriesbyPost(int postID, int x) { PostRepo repo = new PostRepo(); List <Category> cats = repo.GetCategoryByPost(postID); Assert.AreEqual(x, cats.Count()); }
public IActionResult GetAllPosts() { var items = PostRepo.GetAllPosts(); items = RefreshAuthorMaps(items); return(new OkObjectResult(items)); }
public async Task <ActionResult <Post> > Upload([FromBody] UploadArgument upload) { User user = Request.GetUser(); if (user == null) { return(Unauthorized()); } List <byte[]> images = await upload.ParseImages(); string contents = upload.contents.Trim(); Post post; if (upload.groupAuthor == null) { post = await PostRepo.Add(contents, user, images, upload.location); } else { int groupAuthor = (int)upload.groupAuthor; if (await GroupRepo.IsMember(groupAuthor, user)) { post = await PostRepo.AddGroupAuthor(contents, groupAuthor, images, upload.location); } else { return(Unauthorized()); } } return(Ok(post)); }
public void GetPosts() { PostRepo repo = new PostRepo(); List <Post> posts = repo.GetAllPosts().ToList(); Assert.AreEqual(9, posts.Count()); }
public void CanFindFirstPublishedpost() { PostRepo repo = new PostRepo(); int first = repo.FindFirstPublishedPost(); Assert.AreEqual(1, first); }
// GET: Home public ActionResult Index() { postRepo = new PostRepo(database); IEnumerable <Post> posts = postRepo.GetPublicPosts(); return(View(new HomeViewModel(posts))); }
public void CanGetUnapprovedReplies() { PostRepo repo = new PostRepo(); List <Reply> reps = repo.GetUnapprovedReplies(); Assert.AreEqual(1, reps.Count); }
public void CanGetPostForreview() { PostRepo repo = new PostRepo(); List <Post> posts = repo.GetPostForReview(); Assert.AreEqual(1, posts.Count); }
public void CanGetAuthors() { PostRepo repo = new PostRepo(); List <string> authors = repo.GetAllAuthors(); Assert.AreEqual(4, authors.Count); }
public void CanGetStaticPublishedPosts() { PostRepo repo = new PostRepo(); List <Post> posts = repo.GetAllStaticPublished(); Assert.AreEqual(1, posts.Count()); }
public void CanFindLastPub() { PostRepo repo = new PostRepo(); int last = repo.FindLastPublishedPost(); Assert.AreEqual(4, last); }
public void CanGetPublishedPostByTitleSearch(string input, int x) { PostRepo repo = new PostRepo(); List <Post> posts = repo.GetPublishedPostByTitle(input); Assert.AreEqual(x, posts.Count); }
public ActionResult AddPost(int?id) //patametrenin null geldiğini gösterebilmek için ? koyuyoruz { if (id.HasValue) { ViewBag.Header = "Yazı Güncelle"; var post = PostRepo.Get((int)id); var cat = CatagoryRepo.Get(post.CategoryID); WPost vmpost = new WPost(); vmpost.Title = post.Title; vmpost.Content = post.Concent; vmpost.Category = cat.Name; vmpost.PostID = post.PostID; foreach (var item in post.Tags) { vmpost.Tags += item.Name + ","; } return(View(vmpost)); } else { ViewBag.Header = "Yazı Ekle"; return(View()); } }
public void CanLoadCategories() { PostRepo repo = new PostRepo(); List <Category> cats = repo.GetAllCategories(); Assert.AreEqual(3, cats.Count()); }
public IActionResult Create([FromForm] Post p) { PostRepo posts = new PostRepo(); posts.Add(p); return(View()); }
public ActionResult ListPosts() { PostRepo reap = new PostRepo(); var model = reap.GetAllPosts(); return(View(model)); }
public ActionResult DeletePost(Post blog) { PostRepo reap = new PostRepo(); reap.Delete(blog.Id); return(RedirectToAction("ListPosts")); }
public void CanGetHashtagsbyID(int postid, int x) { PostRepo repo = new PostRepo(); List <HashTag> hts = repo.GetHashtagbyPost(postid); Assert.AreEqual(x, hts.Count()); }
public void CanGetUnapprovedComments() { PostRepo repo = new PostRepo(); List <Comment> comms = repo.GetUnapprovedComments(); Assert.AreEqual(2, comms.Count); }
public async Task <IActionResult> ShowPost(int year, string month, int day, string slug, int id = 0) { Post post; if (id > 0) { post = await PostRepo.GetPost(id); } else { post = await PostRepo.GetPost(slug); } // embed ads post.Body = post.Body.Replace("##AD##", ""); // no Ads at the moment exclusive //var body = StringUtils.ReplaceStringInstance(post.Body, "##AD##", App.EmbeddedContentAd, 2, true); //body = StringUtils.ReplaceStringInstance(body, "##AD##", App.WestWindSquareAd, 3, true); //body = body.Replace("##AD##", App.EmbeddedContentAd); var page = Request.Query["page"].FirstOrDefault(); int.TryParse(page, out int pageToDisplay); if (pageToDisplay < 1) { pageToDisplay = 1; } List <string> pages = new List <string>(); if (post.Body.Contains("#PAGEBREAK")) { pages = post.Body.Split(new[] { "#PAGEBREAK" }, StringSplitOptions.RemoveEmptyEntries).ToList(); } if (pages.Count < 1) { pages.Add(post.Body); } var totalPages = pages.Count; if (totalPages == 0) { totalPages = 1; } if (pageToDisplay <= totalPages) { post.Body = pages[pageToDisplay - 1]; } else { totalPages = 1; } return(View(new PostViewModel { Post = post, PostRepo = PostRepo, PageToDisplay = pageToDisplay, TotalPages = totalPages })); }
public void GetPublishedPosts() { PostRepo repo = new PostRepo(); List <Post> posts = repo.GetPublishedPosts(); Assert.AreEqual(5, posts.Count()); Assert.AreEqual("Hello Fellow Monster Hunters", posts[0].PostTitle); }
public void GetPublishedRepliesByComment() { PostRepo repo = new PostRepo(); List <Reply> replies = repo.GetPublishedReplies(1); Assert.AreEqual(1, replies.Count); Assert.AreEqual("I've seen better", replies[0].ReplyText); }
public void CanFindNextPublished(int postid, int x) { PostRepo repo = new PostRepo(); int next = repo.FindNextPublishedPost(postid); Assert.AreEqual(x, next); }
protected void btnDelte_Click(object sender, EventArgs e) { if (int.TryParse(postId.Value, out int id)) { PostRepo.DeletePost(id); Callback("Successfully Deleted", false); } }
public void CanLoadHashtags() { PostRepo repo = new PostRepo(); List <HashTag> Cats = repo.GetHashtags(); Assert.IsNotNull(Cats); Assert.AreEqual(8, Cats.Count()); }
public async Task <ActionResult <List <Post> > > GetGroupPosts(int id, int amount = 20, int offset = 0) { if ((await GroupRepo.Get(id)) == null) { return(NotFound()); } return(Ok(await PostRepo.GetGroupFeedById(id, amount, offset))); }