Пример #1
0
        public ActionResult Search()
        {
            ViewBag.Title = "找商铺";
            string str_QuYu      = Request.QueryString["quyu"] ?? null;      // 城区
            string str_PriceRent = Request.QueryString["pricerent"] ?? null; // pricerent
            string str_PriceSale = Request.QueryString["pricesale"] ?? null; // sale
            string str_Status    = Request.QueryString["status"] ?? null;    // 出租出售
            string str_OpenTime  = Request.QueryString["opentime"] ?? null;  // 开盘时间

            int    IDQuYu      = GetID(str_QuYu);
            int    IDPriceRent = GetID(str_PriceRent);
            int    IDPriceSale = GetID(str_PriceSale);
            int    IDStatus    = GetID(str_Status);
            int    IDPrice     = 0;
            string isSale      = "";
            int    OpenTimeId  = GetID(str_OpenTime);

            if (IDStatus == 145)
            {
                //  出租
                IDStatus    = 145;
                IDPrice     = IDPriceRent;
                IDPriceSale = 0;
                isSale      = "false";
            }
            else if (IDStatus == 144)
            {
                IDPrice     = IDPriceSale;
                IDPriceRent = 0;
                isSale      = "true";
            }
            string queryString = Request.Url.PathAndQuery;

            ViewBag.Filter = FilterBuilder(IDQuYu, IDPrice, IDStatus, OpenTimeId, queryString);
            // search
            int PageIndex = 1; // 页码从1 开始

            int.TryParse(Request.QueryString["PageIndex"], out PageIndex);
            if (PageIndex == 0)
            {
                PageIndex = 1;
            }

            var searchCriteria = new ShopRoomCriteria();

            searchCriteria.PageIndex = PageIndex;
            searchCriteria.PageSize  = 5;

            // searchCriteria.AreaId = IDQuYu;
            searchCriteria.PriceRentId = IDPriceRent;
            searchCriteria.PriceSaleId = IDPriceSale;
            searchCriteria.isSale      = isSale;
            searchCriteria.OpenTimeId  = GetDaysByOpenTime(OpenTimeId);

            searchCriteria.Keys = Request["keys"];
            ViewBag.Keys        = searchCriteria.Keys;

            var AreaItemList = _iShopAttributesService.GetListByAttributeId(AttrQuyuId);
            var AreaItem     = AreaItemList.Where(m => m.Id == IDQuYu).FirstOrDefault();

            if (AreaItem != null)
            {
                searchCriteria.distinct = AreaItem.ValueStr;
            }

            var searchResult = _iShopRoomService.GetSearch(searchCriteria);

            ViewBag.searchResult = searchResult;

            // 分页
            int PageCount = 1;

            if (searchResult.Item2.Total == 0)
            {
                PageCount = 0;
            }
            else if (searchResult.Item2.Total <= searchResult.Item2.Top)
            {
                PageCount = 1;
            }
            else
            {
                int mote = searchResult.Item2.Total % searchResult.Item2.Top;
                if (mote == 0)
                {
                    PageCount = searchResult.Item2.Total / searchResult.Item2.Top;
                }
                else
                {
                    PageCount = searchResult.Item2.Total / searchResult.Item2.Top + 1;
                }
            }

            ViewBag.pager = GetPageIndexFilter(queryString, PageIndex, PageCount);

            return(View());
        }
Пример #2
0
        public ActionResult List()
        {
            ViewBag.Title = "找需求";
            string str_QuYu   = Request.QueryString["quyu"] ?? null;   // 城区
            string str_type   = Request.QueryString["type"] ?? null;   // 物业类型
            string str_Status = Request.QueryString["status"] ?? null; // 出租出售

            int    IDQuYu   = GetID(str_QuYu);
            int    IDType   = GetID(str_type);
            int    IDStatus = GetID(str_Status);
            string isSale   = "";

            if (IDStatus == 0 || IDStatus == 197)
            {
                //  求租
                IDStatus = 197;
                isSale   = "false";
            }
            else if (IDStatus == 198)
            {
                isSale = "true";
            }
            string queryString = Request.Url.PathAndQuery;

            ViewBag.Filter = FilterBuilder(IDStatus, IDQuYu, IDType, queryString);
            // search
            int PageIndex = 1; // 页码从1 开始

            int.TryParse(Request.QueryString["PageIndex"], out PageIndex);
            if (PageIndex == 0)
            {
                PageIndex = 1;
            }

            var searchCriteria = new ShopPostingsCriteria();

            searchCriteria.PageIndex = PageIndex;
            searchCriteria.PageSize  = 6;

            // searchCriteria.AreaId = IDQuYu;
            searchCriteria.isSale = isSale;
            searchCriteria.Keys   = Request["keys"];
            ViewBag.Keys          = searchCriteria.Keys;

            var AreaItemList = _iShopAttributesService.GetListByAttributeId(AttrQuyuId);
            var AreaItem     = AreaItemList.Where(m => m.Id == IDQuYu).FirstOrDefault();

            if (AreaItem != null)
            {
                searchCriteria.distinct = AreaItem.ValueStr;
            }

            var TypeItemList = _iShopAttributesService.GetListByAttributeId(AttrTypeId);
            var TypeItem     = TypeItemList.Where(m => m.Id == IDType).FirstOrDefault();

            if (TypeItem != null)
            {
                searchCriteria.PType = TypeItem.ValueStr;
            }

            var searchResult = _iShopPostingsService.GetSearch(searchCriteria);

            ViewBag.searchResult = searchResult;

            // 分页
            int PageCount = 1;

            if (searchResult.Item2.Total == 0)
            {
                PageCount = 0;
            }
            else if (searchResult.Item2.Total <= searchResult.Item2.Top)
            {
                PageCount = 1;
            }
            else
            {
                int mote = searchResult.Item2.Total % searchResult.Item2.Top;
                if (mote == 0)
                {
                    PageCount = searchResult.Item2.Total / searchResult.Item2.Top;
                }
                else
                {
                    PageCount = searchResult.Item2.Total / searchResult.Item2.Top + 1;
                }
            }

            ViewBag.pageCount = 0;
            ViewBag.pager     = GetPageIndexFilter(queryString, PageIndex, PageCount);
            var tuijian = new ProjectSearchCriteria();

            tuijian.Projecthot = 1;
            var tuijianResult = _IShopProjectService.SearchProject(tuijian);
            var arraylist     = Mapper.Map <ShopProject[], ProjectDetailsViewModel[]>(tuijianResult.Item1).OrderByDescending(p => p.CreatTime).Take(3).ToList();

            ViewBag.array = arraylist;
            return(View());
        }
Пример #3
0
        private string FilterBuilder(int IndustryId, int QuyuID, int SubWayID, int TypeId, int PriceID, int StatusID, int OpenTimeId, string queryString)
        {
            StringBuilder sb      = new StringBuilder();
            StringBuilder sbclear = new StringBuilder();

            #region 行业
            sb.Append("<div class=\"project_st_sl\"><div class=\"project_st_sl_nav \"><div class=\"project_st_sl_nav_hangye\"></div></div><div class=\"project_st_sl_ul\"><div class=\"project_st_sl_li\">");
            string[] regIndustryArray = new string[] { @"industry=DI(\d+\&?)" };
            //不限
            sb.AppendFormat("{0}", GetHrefLinkReset(queryString, regIndustryArray, IndustryId, "不限"));
            var IndustryRange = _iShopAttributesService.GetListByAttributeId(AttrIndustryId);
            //列表
            foreach (var AttrValueItem in IndustryRange)
            {
                if (AttrValueItem.Id == IndustryId)
                {
                    sb.AppendFormat("<a class='on'>{0}</a>", AttrValueItem.ValueStr);
                    string strclear = GetHrefLinkClear(queryString, regIndustryArray, IndustryId, AttrValueItem.ValueStr);
                    sbclear.Append(strclear);
                }
                else
                {
                    sb.AppendFormat("{0}", GetHrefLinkCommon(queryString, @"industry=DI(\d+)", "industry=DI", AttrValueItem.Id, AttrValueItem.ValueStr));
                }
            }
            sb.Append("</div></div><div class=\"clear\"></div></div>");
            #endregion

            #region 区域
            string regkey = "quyu";
            sb.Append("<div class=\"project_st_sl\"><div class=\"project_st_sl_nav \"><div class=\"project_st_sl_nav_area\"></div></div><div class=\"project_st_sl_ul\"><div class=\"project_st_sl_li\">");
            string[] regQuYuArray = new string[] { regkey + @"=DI(\d+\&?)" };
            //不限
            sb.AppendFormat("{0}", GetHrefLinkReset(queryString, regQuYuArray, QuyuID, "不限"));
            var QuYuRange = _iShopAttributesService.GetListByAttributeId(AttrQuyuId);
            //列表
            foreach (var AttrValueItem in QuYuRange)
            {
                if (AttrValueItem.Id == QuyuID)
                {
                    sb.AppendFormat("<a class='on'>{0}</a>", AttrValueItem.ValueStr);
                    string strclear = GetHrefLinkClear(queryString, regQuYuArray, QuyuID, AttrValueItem.ValueStr);
                    sbclear.Append(strclear);
                }
                else
                {
                    sb.AppendFormat("{0}", GetHrefLinkCommon(queryString, regkey + @"=DI(\d+)", regkey + "=DI", AttrValueItem.Id, AttrValueItem.ValueStr));
                }
            }
            sb.Append("</div></div><div class=\"clear\"></div></div>");
            #endregion

            #region 地铁
            regkey = "subway";
            sb.Append("<div class=\"project_st_sl\"><div class=\"project_st_sl_nav \"><div class=\"project_st_sl_nav_subway\"></div></div><div class=\"project_st_sl_ul\"><div class=\"project_st_sl_li\">");
            string[] regSubwayArray = new string[] { regkey + @"=DI(\d+\&?)" };
            //不限
            sb.AppendFormat("{0}", GetHrefLinkReset(queryString, regSubwayArray, SubWayID, "不限"));
            var SubwayRange = _iShopAttributesService.GetListByAttributeId(AttrSubwayId);
            //列表
            foreach (var AttrValueItem in SubwayRange)
            {
                if (AttrValueItem.Id == SubWayID)
                {
                    sb.AppendFormat("<a class='on'>{0}</a>", AttrValueItem.ValueStr);
                    string strclear = GetHrefLinkClear(queryString, regSubwayArray, SubWayID, AttrValueItem.ValueStr);
                    sbclear.Append(strclear);
                }
                else
                {
                    sb.AppendFormat("{0}", GetHrefLinkCommon(queryString, regkey + @"=DI(\d+)", regkey + "=DI", AttrValueItem.Id, AttrValueItem.ValueStr));
                }
            }
            sb.Append("</div></div><div class=\"clear\"></div></div>");
            #endregion

            #region 类型(业态
            regkey = "type";
            sb.Append("<div class=\"project_st_sl\"><div class=\"project_st_sl_nav \"><div class=\"project_st_sl_nav_leixing\"></div></div><div class=\"project_st_sl_ul\"><div class=\"project_st_sl_li\">");
            string[] regTyperray = new string[] { regkey + @"=DI(\d+\&?)" };
            //不限
            sb.AppendFormat("{0}", GetHrefLinkReset(queryString, regTyperray, TypeId, "不限"));
            var TypeRange = _iShopAttributesService.GetListByAttributeId(AttrTypeId);
            //列表
            foreach (var AttrValueItem in TypeRange)
            {
                if (AttrValueItem.Id == TypeId)
                {
                    sb.AppendFormat("<a class='on'>{0}</a>", AttrValueItem.ValueStr);
                    string strclear = GetHrefLinkClear(queryString, regTyperray, TypeId, AttrValueItem.ValueStr);
                    sbclear.Append(strclear);
                }
                else
                {
                    sb.AppendFormat("{0}", GetHrefLinkCommon(queryString, regkey + @"=DI(\d+)", regkey + "=DI", AttrValueItem.Id, AttrValueItem.ValueStr));
                }
            }
            sb.Append("</div></div><div class=\"clear\"></div></div>");
            #endregion

            #region 状态 144 出售, 145 出租
            regkey = "status";
            sb.Append("<div class=\"project_st_sl\"><div class=\"project_st_sl_nav \"><div class=\"project_st_sl_nav_status\"></div></div><div class=\"project_st_sl_ul\"><div class=\"project_st_sl_li\">");
            string[] regStatusArray = new string[] { regkey + @"=DI(\d+\&?)" };
            //不限
            sb.AppendFormat("{0}", GetHrefLinkReset(queryString, regStatusArray, StatusID, "不限"));
            var StatusRane = _iShopAttributesService.GetListByAttributeId(AttrStatus);
            //列表
            foreach (var AttrValueItem in StatusRane)
            {
                if (AttrValueItem.Id == StatusID)
                {
                    sb.AppendFormat("<a class='on'>{0}</a>", AttrValueItem.ValueStr);
                    string strclear = GetHrefLinkClear(queryString, regStatusArray, StatusID, AttrValueItem.ValueStr);
                    sbclear.Append(strclear);
                }
                else
                {
                    sb.AppendFormat("{0}", GetHrefLinkCommon(queryString, regkey + @"=DI(\d+)", regkey + "=DI", AttrValueItem.Id, AttrValueItem.ValueStr));
                }
            }
            sb.Append("</div></div><div class=\"clear\"></div></div>");
            #endregion

            // 价格
            #region 价格
            if (StatusID > 0)
            {
                regkey = "pricesale";
                int AttrPriceId = AttrPriceSaleId;
                if (StatusID == 145)
                {
                    regkey      = "pricerent";
                    AttrPriceId = AttrPriceRentId;
                }
                sb.Append("<div class=\"project_st_sl\"><div class=\"project_st_sl_nav \"><div class=\"project_st_sl_nav_price\"></div></div><div class=\"project_st_sl_ul\"><div class=\"project_st_sl_li\">");
                string[] regPriceArray = new string[] { regkey + @"=DI(\d+\&?)" };
                //不限
                sb.AppendFormat("{0}", GetHrefLinkReset(queryString, regPriceArray, PriceID, "不限"));
                if (StatusID == 145)
                {
                    // rent
                    var PriceRane = _iShopAttributesService.GetBasPriceRentRange();
                    //列表
                    foreach (var AttrValueItem in PriceRane)
                    {
                        if (AttrValueItem.Id == PriceID)
                        {
                            sb.AppendFormat("<a class='on'>{0}</a>", AttrValueItem.RPName);
                            string strclear = GetHrefLinkClear(queryString, regPriceArray, PriceID, AttrValueItem.RPName);
                            sbclear.Append(strclear);
                        }
                        else
                        {
                            sb.AppendFormat("{0}", GetHrefLinkCommon(queryString, regkey + @"=DI(\d+)", regkey + "=DI", AttrValueItem.Id, AttrValueItem.RPName));
                        }
                    }
                }
                else
                {
                    // sale
                    //列表
                    var PriceRane = _iShopAttributesService.GetBasPriceSaleRange();
                    foreach (var AttrValueItem in PriceRane)
                    {
                        if (AttrValueItem.PRID == PriceID)
                        {
                            sb.AppendFormat("<a class='on'>{0}</a>", AttrValueItem.PRName);
                            string strclear = GetHrefLinkClear(queryString, regPriceArray, PriceID, AttrValueItem.PRName);
                            sbclear.Append(strclear);
                        }
                        else
                        {
                            sb.AppendFormat("{0}", GetHrefLinkCommon(queryString, regkey + @"=DI(\d+)", regkey + "=DI", AttrValueItem.PRID, AttrValueItem.PRName));
                        }
                    }
                }
                sb.Append("</div></div><div class=\"clear\"></div></div>");
            }
            #endregion


            #region 开盘
            regkey = "opentime";
            sb.Append("<div class=\"project_st_sl\"><div class=\"project_st_sl_nav \"><div class=\"project_st_sl_nav_opentime\"></div></div><div class=\"project_st_sl_ul project_st_sl_ul_opentime \"><div class=\"project_st_sl_li\">");
            string[] regOpenTimeArray = new string[] { regkey + @"=DI(\d+\&?)" };
            //不限
            sb.AppendFormat("{0}", GetHrefLinkReset(queryString, regOpenTimeArray, OpenTimeId, "不限"));
            var OpenTimeRange = _iShopAttributesService.GetListByAttributeId(AttrOpenTimeId);
            //列表
            foreach (var AttrValueItem in OpenTimeRange)
            {
                if (AttrValueItem.Id == OpenTimeId)
                {
                    sb.AppendFormat("<a class='on'>{0}</a>", AttrValueItem.ValueStr);
                    string strclear = GetHrefLinkClear(queryString, regOpenTimeArray, OpenTimeId, AttrValueItem.ValueStr);
                    sbclear.Append(strclear);
                }
                else
                {
                    sb.AppendFormat("{0}", GetHrefLinkCommon(queryString, regkey + @"=DI(\d+)", regkey + "=DI", AttrValueItem.Id, AttrValueItem.ValueStr));
                }
            }
            sb.Append("</div></div><div class=\"clear\"></div></div>");
            #endregion
            string clearlink = sbclear.ToString();
            if (!string.IsNullOrEmpty(clearlink))
            {
                sb.Append("<div class=\"project_st_sl\"><div class=\"project_st_sl_nav\"><div class=\"project_st_sl_nav_check\"></div></div><div class=\"project_st_sl_ul\"><div class=\"project_st_sl_li\">");
                sb.Append(sbclear.ToString());
                sb.Append("</div></div><div class=\"clear\"></div></div>");
            }
            return(sb.ToString());
        }