public ListPostViewModel(IBlogRepository blogRepository, string text, string type, int pageNo) { _blogRepository = blogRepository; switch (type) { case "Category": { Posts = _blogRepository.PostsForCategory(text, pageNo - 1, itemsPerPage); TotalPosts = _blogRepository.TotalPostsForCategory(text); Category = _blogRepository.Category(text); PagingInfo = new PagingInfo { CurrentPage = pageNo, ItemsPerPage = itemsPerPage, TotalItems = TotalPosts, CurrentCategory = text }; break; } case "Tag": { Posts = _blogRepository.PostsForTags(text, pageNo - 1, itemsPerPage); TotalPosts = _blogRepository.TotalPostsForTag(text); Tag = _blogRepository.Tag(text); CurrentTag = Tag.Name; PagingInfo = new PagingInfo { CurrentPage = pageNo, ItemsPerPage = itemsPerPage, TotalItems = TotalPosts, CurrentTag = text }; break; } default: { Posts = _blogRepository.PostsForSearch(text, pageNo - 1, itemsPerPage); TotalPosts = _blogRepository.TotalPostsForSearch(text); CurrentSearchString = text; PagingInfo = new PagingInfo { CurrentPage = pageNo, ItemsPerPage = itemsPerPage, TotalItems = TotalPosts, CurrentSearchString = text }; break; } } }