Exemplo n.º 1
0
        public ActionResult Search(HouseSearchOptionModel houseSearchOption)
        {
            long    cityId = FrontHelper.GetCityId(this.HttpContext);
            CityDTO city   = CityService.GetById(cityId);

            RegionDTO[] regions = RegionService.GetAll(cityId);
            int         monthRentStart, monthRentEnd;

            ParseMonthRent(houseSearchOption.MonthRent, out monthRentStart, out monthRentEnd);
            HouseSearchOptions houseSearchOptions = new HouseSearchOptions
            {
                CityId         = cityId,
                RegionId       = houseSearchOption.RegionId,
                KeyWords       = houseSearchOption.KeyWords,
                TypeId         = houseSearchOption.TypeId,
                MonthRentStart = monthRentStart,
                MonthRentEnd   = monthRentEnd
            };
            var houses = HouseService.Search(houseSearchOptions);

            HouseSearchViewModel houseSearchView = new HouseSearchViewModel
            {
                City    = city,
                Regions = regions,
                Houses  = houses
            };

            return(View(houseSearchView));
        }
Exemplo n.º 2
0
        public ActionResult Search(long typeId, string keyWords, string monthRent,
                                   string orderByType, long?regionId)
        {
            //获得当前用户城市Id
            long cityId = FrontUtils.GetCityId(HttpContext);

            //获取城市下所有区域
            var regions = regionService.GetAll(cityId);
            HouseSearchViewModel model = new HouseSearchViewModel();

            model.regions = regions;

            HouseSearchOptions searchOpt = new HouseSearchOptions();

            searchOpt.CityId       = cityId;
            searchOpt.CurrentIndex = 1;

            //解析月租部分
            int?startMonthRent;
            int?endMonthRent;

            //ref/out
            ParseMonthRent(monthRent, out startMonthRent, out endMonthRent);
            searchOpt.EndMonthRent   = endMonthRent;
            searchOpt.StartMonthRent = startMonthRent;



            searchOpt.Keywords = keyWords;
            switch (orderByType)
            {
            case "MonthRentAsc":
                searchOpt.OrderByType = HouseSearchOrderByType.MonthRentAsc;
                break;

            case "MonthRentDesc":
                searchOpt.OrderByType = HouseSearchOrderByType.MonthRentDesc;
                break;

            case "AreaAsc":
                searchOpt.OrderByType = HouseSearchOrderByType.AreaAsc;
                break;

            case "AreaDesc":
                searchOpt.OrderByType = HouseSearchOrderByType.AreaDesc;
                break;
            }
            searchOpt.PageSize = 10;
            searchOpt.RegionId = regionId;
            searchOpt.TypeId   = typeId;

            //开始搜索
            var searchResult = houseService.Search(searchOpt);

            model.houses = searchResult.result;
            //当前用户城市Id

            return(View(model));
        }
Exemplo n.º 3
0
        public ActionResult Search(string keyWord, string monthRent, string orderByType, long?regionId, long typeId)
        {
            //获得当前用户城市ID
            long cityId = FrontUtils.GetCityId(HttpContext);

            //获得城市区域
            var regions = regionService.GetAll(cityId);
            HouseSearchViewModel model = new HouseSearchViewModel
            {
                Regions = regions,
            };


            int?startMonthRent;
            int?endMonthRent;

            ParseMonthRent(monthRent, out startMonthRent, out endMonthRent);

            var orderByTypeEnum = OrderByType.CreateDateDesc;

            switch (orderByType)
            {
            case "MonthRentAsc":
                orderByTypeEnum = OrderByType.MonthRentAsc;
                break;

            case "MonthRentDesc":
                orderByTypeEnum = OrderByType.MonthRentDesc;
                break;

            case "AreaAsc":
                orderByTypeEnum = OrderByType.AreaAsc;
                break;

            case "AreaDesc":
                orderByTypeEnum = OrderByType.AreaDesc;
                break;
            }
            HouseSearchOptions searchOption = new HouseSearchOptions
            {
                CityId         = cityId,
                CurrentIndex   = 1,
                StartMonthRent = startMonthRent,
                EndMonthRent   = endMonthRent,
                Keywords       = keyWord,
                OrderByType    = orderByTypeEnum,
                PageSize       = 10,
                RegionId       = regionId,
                TypeId         = typeId,
            };
            var searchResult = houseService.Search(searchOption);

            model.Houses = searchResult.result;

            return(View(model));
        }
Exemplo n.º 4
0
        public ActionResult Search(long typeId, string keyWords, string monthRent, string oderByType, long?regionId)
        {
            //获取当前用户城市ID
            var cityId = FrontHelper.GetCityId(HttpContext);
            //获取城市下所有区域
            var regions = RegionService.GetAll(cityId);
            HouseSearchViewModel viewModel = new HouseSearchViewModel();

            viewModel.Regions = regions;
            HouseSearchOptions searchOptions = new HouseSearchOptions();

            searchOptions.TypeId       = typeId;
            searchOptions.Keywords     = keyWords;
            searchOptions.PageSize     = 10;
            searchOptions.RegionId     = regionId;
            searchOptions.CityId       = cityId;
            searchOptions.CurrentIndex = 1;

            switch (oderByType)
            {
            case "MonthRentDesc":
                searchOptions.OrderByType = HouseSearchOrderByType.MonthRentDesc;
                break;

            case "MonthRentAsc":
                searchOptions.OrderByType = HouseSearchOrderByType.MonthRentAsc;
                break;

            case "AreaAsc":
                searchOptions.OrderByType = HouseSearchOrderByType.AreaAsc;
                break;

            case "AreaDesc":
                searchOptions.OrderByType = HouseSearchOrderByType.AreaDesc;
                break;
            }
            //解析月租部分
            int?startMonthRent;
            int?endMonthRent;

            ParseMonthRent(monthRent, out startMonthRent, out endMonthRent);

            searchOptions.StartMonthRent = startMonthRent;
            searchOptions.EndMonthRent   = endMonthRent;

            var houseSearchResult = HouseService.Search(searchOptions);

            viewModel.Houses = houseSearchResult.result;
            return(View(viewModel));
        }