public ListCategoriesModel ListCategoriesAndCount() { var categories = this.categoryRepository.All() .OrderByDescending(p => p.Articles.Count()) .To <CategoryIdAndNameModel>().ToArray(); var model = new ListCategoriesModel { Categories = categories }; return(model); }
public async Task <IActionResult> ListCategories(string propertyType, string propertyCategory) { try { PropertyType type = (PropertyType)Enum.Parse(typeof(PropertyType), propertyType); PropertyCategory category = (PropertyCategory)Enum.Parse(typeof(PropertyCategory), propertyCategory); var model = new ListCategoriesModel { properties = await _propertyService.GetPropertiesByTypeAndCategoryAsync(type, category) }; ViewBag.Cities = new SelectList(await _cityService.GetCitiesAsync(), "CityId", "Name"); return(View(model)); } catch (Exception ex) { return(View()); } }