コード例 #1
0
        public async Task <PagedCollection <PropertyInfoModel> > ListProperties(string user, PropertyFilterSpecification filter, int pageNumber, int itemsPerPage, SortOptions sortOptions)
        {
            var rootItems = await _propertyRepository.ListWithFilterAsync(new PropertyFilter(filter));

            rootItems = GetSortedProperties(rootItems, sortOptions);

            var items = _mapper.Map <IEnumerable <EstateUnit>, IEnumerable <PropertyInfoModel> >(rootItems);

            var paginatedItems = PagedCollection <PropertyInfoModel> .Create(items, pageNumber, itemsPerPage);

            foreach (var estateUnit in paginatedItems)
            {
                estateUnit.IsMarkedAsFavourite = _favouritesRepository.IsFavouriteForUser(estateUnit.Id, user);
            }

            return(paginatedItems);
        }