Example #1
0
        /// <summary>
        /// Gets all subcategories when a parent category link is clicked.
        /// </summary>
        /// <param name="categoryId">the id of the parent category</param>
        /// <param name="subCategoryId">the id of a subcategory</param>
        /// <returns>The Post Index View</returns>
        public ActionResult GetSubCategoriesForLink(int categoryId, int subCategoryId)
        {
            PostModel model = new PostModel();

            model.UserLoginName = claimsHelper.GetUserNameFromClaim((ClaimsIdentity)User.Identity);

            GetAllPostsForSubCategoryQuery sQuery =
                new GetAllPostsForSubCategoryQuery(new Category(categoryId, subCategoryId));

            model.AllPostsForCategory = commandBus.ProcessQuery(sQuery);

            model.CategoryTitle = Enumeration.TryFindById <SubCategoryEnum>(subCategoryId).DisplayValue;

            return(View(ViewNames.PostIndex, model));
        }
Example #2
0
 /// <summary>
 /// Handler for GetAllPostsForSubCategoryQuery query
 /// </summary>
 /// <param name="query">the GetAllPostsForSubCategory Query</param>
 /// <returns>a collection of post previews for a subcategory</returns>
 public IEnumerable <PostPreview> Handle(GetAllPostsForSubCategoryQuery query)
 {
     return(postRepository.GetAllPostsForSubCategory(query.category));
 }