public ActionResult ManagePosts([DefaultValue(1)] int page, string type) { var status = type != null ? (int)Enum.Parse(typeof(PostStatus), type, true) : 0; var allPosts = _postRepository.GetPostsByUserID(GetUserId(), ItemEntryType); var allPostsByStatus = allPosts.GetPostsByStatus(status); var postModel = new AdminPostOrPageViewModel { Posts = allPostsByStatus.Skip((page - 1) * _itemsPerPage).Take(_itemsPerPage).ToList(), PagingInfo = new PagingInformation { CurrentPage = page, ItemsPerPage = _itemsPerPage, TotalItems = allPostsByStatus.Count }, Type = type, AllPostsCount = allPosts.Count, PrivatePostsCount = allPosts.Count(p => p.IsPrivate), OneTimeCode = GetToken(), Title = SettingsRepository.BlogName }; return View(postModel); }
public ActionResult ManagePublicPosts([DefaultValue(1)] int page) { var allUsers = _userRepository.GetAllUsers(); var allPosts = _postRepository.GetPosts(1, 1); var filteredPosts = allPosts.Skip((page - 1)*5).Take(5).ToList(); filteredPosts.ForEach(post => post.OwnerUserName = allUsers.Single(u => u.UserID == post.OwnerUserID).UserDisplayName); var postModel = new AdminPostOrPageViewModel { Posts = allPosts.Skip((page - 1) * 5).Take(5).ToList(), PagingInfo = new PagingInformation { CurrentPage = page, ItemsPerPage = 5, TotalItems = allPosts.Count }, AllPostsCount = allPosts.Count, Title = SettingsRepository.BlogName }; return View(postModel); }
public ActionResult ManagePublicPosts([DefaultValue(1)] int page) { if (!User.IsInRole("SuperAdmin") && !User.IsInRole("Admin")) { return RedirectToAction("Index", "Home", new { Area = "" }); } var allUsers = _userRepository.GetAllUsers().ToList(); var allPosts = _postRepository.GetPosts(1, 1); var filteredPosts = allPosts.Skip((page - 1) * 5).Take(5).ToList(); filteredPosts.ForEach(post => { var user = allUsers.Single(u => u.UserID == post.OwnerUserID); post.OwnerUserName = user.UserDisplayName; post.UserName = user.UserName; }); var postModel = new AdminPostOrPageViewModel { Posts = allPosts.Skip((page - 1) * 5).Take(5).ToList(), PagingInfo = new PagingInformation { CurrentPage = page, ItemsPerPage = 5, TotalItems = allPosts.Count }, AllPostsCount = allPosts.Count, Title = SettingsRepository.BlogName }; return View(postModel); }