public async Task <IActionResult> Index(PropertyListCriteriaModel criteria, int pageIndex = 0, int pageSize = 20) { var properties = await _propertyService.ListAsync(pageIndex : pageIndex, pageSize : pageSize, userId : criteria.UserId, propertyType : (PropertyType?)criteria.PropertyType, status : (PropertyStatus?)criteria.Status, transactionType : (TransactionType?)criteria.TransactionType, countyId : criteria.CountyId, cityId : criteria.CityId, priceFrom : criteria.PriceFrom, priceTo : criteria.PriceTo, telephone : criteria.Telephone, code : criteria.Code ); var model = new PropertyListModel() { Criteria = (criteria.UserId.HasValue || criteria.PropertyType.HasValue || criteria.Status.HasValue || criteria.TransactionType.HasValue || criteria.CountyId.HasValue || criteria.CityId.HasValue || criteria.PriceFrom.HasValue || criteria.PriceTo.HasValue || !string.IsNullOrEmpty(criteria.Telephone) || criteria.Code.HasValue) ? criteria : null, Properties = _mapper.Map <PagedResultModel <PropertyListItemModel> >(properties), Users = _mapper.Map <IEnumerable <SelectListItem> >(await _userRepository.ListAsync(new UserFilterSpecification(onlyActive: true))), Counties = _mapper.Map <IEnumerable <SelectListItem> >(await _countyRepository.ListAsync(new CountyFilterSpecification())), Cities = criteria.CountyId.HasValue ? _mapper.Map <IEnumerable <SelectListItem> >(await _cityRepository.ListAsync(new CityFilterSpecification(criteria.CountyId.Value))) : null }; return(View(model)); }