public ActionResult ByCategory(string category) { var view = new HomeView(); view.NavView.SelectedMenuItem = "nav-blog"; var request = new GetBlogsByCategoryRequest(); var catrequest = new GetBlogCategoryByNameRequest(); catrequest.CategoryName = category.Replace("-", " "); request.CategoryID = _categoryService.GetByName(catrequest).Category.ID; view.Categories = _categoryService.GetAll().Categories; var response = _blogService.GetByCategory(request); view.Posts = response.BlogList; return(View("BlogsByCategory", view)); }
public GetBlogCategoryResponse GetByName(GetBlogCategoryByNameRequest request) { var response = new GetBlogCategoryResponse(); Query query = new Query(); query.Add(new Criterion("Name", request.CategoryName, CriteriaOperator.Equal)); var cat = _repository.FindBy(query); if (cat != null) { response.Success = true; response.Message = "Blog Categories Retrieved Successfully!"; response.Category = cat.FirstOrDefault <IBlogCategory>(); } else { response.Success = false; response.Message = "Blog Categories Retrieved Failed!"; } return(response); }