/// <summary> /// Method that grabs all the posts when the user clicks on a category link. /// </summary> /// <param name="categoryId">The category id of posts to find.</param> /// <returns>The Post Index View</returns> public ActionResult GetPostsForCategory(int categoryId) { PostModel model = new PostModel(); model.UserLoginName = claimsHelper.GetUserNameFromClaim((ClaimsIdentity)User.Identity); GetAllPostsForCategoryQuery postQuery = new GetAllPostsForCategoryQuery(new Category(categoryId)); model.AllPostsForCategory = commandBus.ProcessQuery(postQuery); model.CategoryTitle = Enumeration.TryFindById <CategoryEnum>(categoryId).DisplayValue; return(View(ViewNames.PostIndex, model)); }
/// <summary> /// The Index method for the post controller. /// </summary> /// <param name="loginName">login name of the currently active user.</param> /// <returns>The Team Member Post View</returns> public ActionResult Index(string loginName) { PostModel model = new PostModel(); List <PostPreview> postPreviewList = new List <PostPreview>(); model.UserLoginName = claimsHelper.GetUserNameFromClaim((ClaimsIdentity)User.Identity); for (int i = 1; i <= 8; i++) { Category current = new Category(i); GetAllPostsForCategoryQuery carouselQuery = new GetAllPostsForCategoryQuery(current); IEnumerable <PostPreview> postList = commandBus.ProcessQuery(carouselQuery); foreach (PostPreview post in postList) { post.CategoryId = i; postPreviewList.Add(post); } } model.PostPreviews = postPreviewList; return(View(ViewNames.TeamMemberPostHome, model)); }
/// <summary> /// Handler for GetAllPostsForCategoryQuery query /// </summary> /// <param name="query">the GetAllPostsForCategory Query</param> /// <returns>a collection of post previews to display for a selected category</returns> public IEnumerable <PostPreview> Handle(GetAllPostsForCategoryQuery query) { return(postRepository.GetAllPostsForCategoryFixed(query.category)); }