Пример #1
0
        public ActionResult ForgetPassword(string phoneNum, string verifyCode, string newPassword)
        {
            if (verifyCode != (string)TempData["verifyCode"])
            {
                return(Json(new AjaxResult()
                {
                    Status = "error", ErrorMsg = "验证码错误"
                }));
            }
            var checkIsPhoneNum = userService.GetByPhoneNum(phoneNum);
            var userId          = FrontUtils.GetUserId(HttpContext);

            if (checkIsPhoneNum != null)
            {
                userService.UpdatePwd(userId.Value, newPassword);
                return(Json(new AjaxResult {
                    Status = "ok"
                }));
            }
            else
            {
                return(Json(new AjaxResult {
                    Status = "error", ErrorMsg = "修改密码错误"
                }));
            }
        }
Пример #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));
        }
Пример #3
0
        public ActionResult Search2(long typeId, string keyWords, string monthRent,
                                    string orderByType, long?regionId)
        {
            long cityId  = FrontUtils.GetCityId(HttpContext);
            var  regions = regionService.GetAll(cityId);

            return(View(regions));
        }
Пример #4
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));
        }
Пример #5
0
        /// <summary>
        /// 加载更多的数据配合search2实现下拉加载
        /// </summary>
        /// <param name="typeId"></param>
        /// <param name="keyWords">关键字</param>
        /// <param name="monthRent">价格区间</param>
        /// <param name="orderByType">排序规则</param>
        /// <param name="regionId">区域id</param>
        /// <param name="pageIndex">加载第几页的数据</param>
        /// <returns></returns>
        public ActionResult LoadMore(long typeId, string keyWords, string monthRent,
                                     string orderByType, long?regionId, int pageIndex)
        {
            //获得当前用户城市Id
            long cityId = FrontUtils.GetCityId(HttpContext);
            //创建搜索条件的类
            HouseSearchOptions searchOpt = new HouseSearchOptions();

            searchOpt.CityId = cityId;
            //加载第几页的数据
            searchOpt.CurrentIndex = pageIndex;

            //解析月租部分
            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;
            //区域的id
            searchOpt.RegionId = regionId;
            //房屋的类型(合租,整租)
            searchOpt.TypeId = typeId;

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

            return(Json(new AjaxResult {
                Status = "ok", Data = houses
            }));
        }
Пример #6
0
        public ActionResult Index( )
        {
            long   cityId   = FrontUtils.GetCityId(HttpContext);
            string cityName = cityService.GetById(cityId).Name;

            ViewBag.CityName = cityName;
            var cities = cityService.GetAll();

            return(View(cities));
        }
Пример #7
0
        /// <summary>
        /// 下拉加载数据
        /// </summary>
        /// <param name="typeId"></param>
        /// <param name="keyWords">关键字</param>
        /// <param name="monthRent">价格区间</param>
        /// <param name="orderByType">排序规则</param>
        /// <param name="regionId">区域id</param>
        /// <returns></returns>
        public ActionResult Search2(long typeId, string keyWords, string monthRent,
                                    string orderByType, long?regionId)
        {
            //获得当前用户城市Id
            long cityId = FrontUtils.GetCityId(HttpContext);
            //直接把搜索的所有房源传过去,通过下拉加载(页面通过ajax渲染)
            var regions = regionService.GetAll(cityId);

            return(View(regions));
        }
Пример #8
0
        public ActionResult Index()
        {
            //一定能拿到一个CityId
            long   cityId   = FrontUtils.GetCityId(HttpContext);
            string cityName = cityService.GetById(cityId).Name;

            ViewBag.cityName = cityName;
            //不用ViewBag,后面需要改成ViewModel
            var cities = cityService.GetAll();

            return(View(cities));
        }
Пример #9
0
        /// <summary>
        /// 加载数据
        /// </summary>
        /// <param name="typeId"></param>
        /// <param name="keyWords"></param>
        /// <param name="monthRent"></param>
        /// <param name="orderByType"></param>
        /// <param name="regionId"></param>
        /// <param name="pageIndex"></param>
        /// <returns></returns>
        public ActionResult LoadMore(long typeId, string keyWords, string monthRent, string orderByType, long?regionId, int pageIndex)
        {
            //获取城市Id
            long cityId = FrontUtils.GetCityId(HttpContext);

            HouseSearchOptions searchOpt = new HouseSearchOptions();

            searchOpt.CityId       = cityId;
            searchOpt.CurrentIndex = pageIndex;

            //根据月租金
            int?startMonthRent;
            int?endMonthRent;

            ParseMonthRent(monthRent, out startMonthRent, out endMonthRent);
            searchOpt.EndMonthRent   = endMonthRent;
            searchOpt.StartMonthRent = startMonthRent;
            //搜索
            searchOpt.Keywords = keyWords;
            //根据orderByType排序规则搜索
            switch (orderByType)
            {
            case "MonthRentAsc":
                searchOpt.OrderByType = HouseSearchOrderByType.MonthRentAsc;
                break;

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

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

            default:
                searchOpt.OrderByType = HouseSearchOrderByType.AreaDesc;
                break;
            }
            searchOpt.PageSize = 10;
            searchOpt.RegionId = regionId;
            searchOpt.TypeId   = typeId;
            //开始搜索
            var searchResult = houseService.Search(searchOpt);//搜索结果
            var houses       = searchResult.result;

            return(Json(new AjaxResult()
            {
                Status = "ok", Data = houses
            }));
        }
Пример #10
0
        public ActionResult Search(long typeId, string keyWords, string monthRent, string orderByType, long?regionId)
        {  //获得当前城市的Id
            long cityId = FrontUtils.GetCityId(HttpContext);
            HouseSearchViewModel model = new Modals.HouseSearchViewModel();

            //获取这个cityId城市下所有的区域
            model.regions = regionService.GetAll(cityId);
            HouseSearchOptions searchOpt = new HouseSearchOptions();

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

            //根据月租金
            int?startMonthRent;
            int?endMonthRent;

            ParseMonthRent(monthRent, out startMonthRent, out endMonthRent);
            searchOpt.EndMonthRent   = endMonthRent;
            searchOpt.StartMonthRent = startMonthRent;
            //搜索
            searchOpt.Keywords = keyWords;
            //根据orderByType排序规则搜索
            switch (orderByType)
            {
            case "MonthRentAsc":
                searchOpt.OrderByType = HouseSearchOrderByType.MonthRentAsc;
                break;

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

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

            default:
                searchOpt.OrderByType = HouseSearchOrderByType.AreaDesc;
                break;
            }
            searchOpt.PageSize = 10;
            searchOpt.RegionId = regionId;
            searchOpt.TypeId   = typeId;
            //开始搜索
            var searchResult = houseService.Search(searchOpt);//搜索结果

            model.Houses = searchResult.result;
            return(View(model));
        }
Пример #11
0
        /// <summary>
        /// 切换当前用户的城市Id
        /// </summary>
        /// <param name="cityId"></param>
        /// <returns></returns>
        public ActionResult SwitchCityId(long cityId)
        {
            long?userId = FrontUtils.GetUserId(HttpContext);

            if (userId == null)//无人登录
            {
                Session["CityId"] = cityId;
            }
            else
            {
                userService.SetUserCityId((long)userId, cityId);
            }
            return(Json(new AjaxResult {
                Status = "ok"
            }));
        }
Пример #12
0
        public ActionResult MakeAppointment(HouseMakeAppointMentModel model)
        {
            if (!ModelState.IsValid)
            {
                string msg = MVCHelper.GetValidMsg(ModelState);
                return(Json(new AjaxResult()
                {
                    Status = "Error", ErrorMsg = msg
                }));
            }
            long?userId = FrontUtils.GetUserId(HttpContext);

            appService.AddNew(userId, model.Name, model.PhoneNum, model.HouseId, model.VisitDate);
            return(Json(new AjaxResult {
                Status = "ok"
            }));
        }
Пример #13
0
        public ActionResult SwitchCityId(long?cityId)
        {
            //判断session里是否有用户不登录
            long?userId = FrontUtils.GetUserId(HttpContext);

            if (userId == null)//无人登录
            {
                Session["CityId"] = cityId;
            }
            else
            {
                //切换当前用户的城市Id
                userService.SetUserCityId((long)userId, (long)cityId);
            }
            return(Json(new AjaxResult()
            {
                Status = "ok"
            }));;
        }