public async Task GetProperties()
        {
            CurrentPage = 0;

            var requestParams = new PropertyListRequest
            {
                CurrentPage      = CurrentPage,
                PageSize         = PageSize,
                NameFilter       = NameFilter,
                CityFilter       = CityFilter,
                StateFilter      = StateFilter,
                SortColumn       = SortColumn,
                SortAscending    = SortAscending,
                UserIdListFilter = UserIdListFilter,
            };

            var result = await GetPropertiesAsync(requestParams);

            if (result != null)
            {
                Properties.Clear();
                foreach (var p in result.Properties)
                {
                    Properties.Add(p);
                }
                LastResult = result;
                TotalPages = LastResult.TotalPages;
                OnPropertyListUpdated(result);
            }
        }
        private PaginatedPropertyList GetPaginatedPropertyList(PropertyListRequest requestParams)
        {
            var query = PropertiesQuery(requestParams);

            var totalItems = query.Count();

            // if no limit for page size, then page size will be equal to total items so we return all results.
            var pageSize = requestParams.PageSize != PropertyListRequest.NoLimitForPageSize ? requestParams.PageSize : totalItems;

            query = query.Skip(requestParams.CurrentPage * pageSize).Take(pageSize);

            var propertyDtoList = Mapper.Map <IQueryable <Entity.Models.Property>, List <Dto.Models.Property> >(query);

            GenerateUserPhotoLinks(propertyDtoList);

            // If requestParams is not empty, we should have received page info.
            var paginatedList = new PaginatedPropertyList
            {
                Properties  = propertyDtoList,
                CurrentPage = requestParams.CurrentPage,
                PageSize    = pageSize,
                TotalPages  = (int)Math.Ceiling((double)totalItems / pageSize),
                TotalItems  = totalItems
            };

            return(paginatedList);
        }
 private void OnPropertyListUpdated(PaginatedPropertyList result)
 {
     if (PropertyListUpdatedHandler != null)
     {
         var args = new PaginatedPropertyListUpdatedEventArgs()
         {
             LastResult = result
         };
         PropertyListUpdatedHandler(this, args);
     }
 }