public async Task <IActionResult> Filter(PropertyFilterSpecification filterSpecification)
        {
            await _propertyViewModelService.ListProperties(User.Identity.Name,
                                                           filterSpecification,
                                                           Constants.FirstPage,
                                                           Constants.ItemsPerPage,
                                                           SortOptions.Newest);

            return(View());
        }
Example #2
0
        public async Task <IPagedResult <Property> > ListAsync(int pageIndex, int pageSize,
                                                               long?userId = null,
                                                               PropertyType?propertyType       = null,
                                                               PropertyStatus?status           = null,
                                                               TransactionType?transactionType = null,
                                                               long?countyId     = null,
                                                               long?cityId       = null,
                                                               decimal?priceFrom = null,
                                                               decimal?priceTo   = null,
                                                               string telephone  = null,
                                                               long?code         = null)
        {
            var filterSpecification = new PropertyFilterSpecification(
                userId: userId,
                propertyType: propertyType,
                status: status,
                transactionType: transactionType,
                countyId: countyId,
                cityId: cityId,
                priceFrom: priceFrom,
                priceTo: priceTo,
                telephone: telephone,
                id: code
                );
            var filterPaginatedSpecification = new PropertyFilterPaginatedSpecification(pageIndex * pageSize, pageSize,
                                                                                        userId: userId,
                                                                                        propertyType: propertyType,
                                                                                        status: status,
                                                                                        transactionType: transactionType,
                                                                                        countyId: countyId,
                                                                                        cityId: cityId,
                                                                                        priceFrom: priceFrom,
                                                                                        priceTo: priceTo,
                                                                                        telephone: telephone,
                                                                                        id: code
                                                                                        );

            var items = await _propertyRepository.ListAsync(filterPaginatedSpecification);

            var totalItems = await _propertyRepository.CountAsync(filterSpecification);

            return(new PagedResult <Property>(pageIndex, pageSize, totalItems, items));
        }
 public ListWithFilterModel()
 {
     FilterSpecification = new PropertyFilterSpecification();
 }
Example #4
0
        public async Task <Property> GetAsync(long id)
        {
            var spec = new PropertyFilterSpecification(id: id);

            return(await _propertyRepository.SingleAsync(spec));
        }
        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);
        }