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)); }
public ActionResult MakeAppointment(string name, string phoneNum, DateTime visitDate, long houseId) { HouseAppointmentService.AddNewHouseAppointment(FrontHelper.GetUserId(this.HttpContext), name, phoneNum, visitDate, houseId); return(Json(new AjaxResult { Status = "ok" })); }
public ActionResult Search2(long typeId, string keyWords, string monthRent, string oderByType, long?regionId) { //获取当前用户城市ID var cityId = FrontHelper.GetCityId(HttpContext); //获取城市下所有区域 var regions = RegionService.GetAll(cityId); return(View(regions)); }
public ActionResult Index() { long cityId = FrontHelper.GetCityId(this.HttpContext); var cities = CityService.GetAll(); var types = IdNameService.GetByTypeName("房屋类别"); HomeIndexViewModel homeIndexView = new HomeIndexViewModel(); homeIndexView.Cities = cities; homeIndexView.Types = types; return(View(homeIndexView)); }
// GET: public ActionResult Index() { //获取当前用户城市名 var cityId = FrontHelper.GetCityId(HttpContext); var cityName = CityService.GetById(cityId).Name; ViewBag.cityName = cityName; //获取所有城市名 var cities = CityService.GetAll(); return(View(cities)); }
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)); }
public ActionResult LoadMore(long typeId, string keyWords, string monthRent, string oderByType, int currentIndex, long?regionId) { //获取当前用户城市ID var cityId = FrontHelper.GetCityId(HttpContext); HouseSearchOptions searchOptions = new HouseSearchOptions(); searchOptions.TypeId = typeId; searchOptions.Keywords = keyWords; searchOptions.PageSize = 10; searchOptions.RegionId = regionId; searchOptions.CityId = cityId; searchOptions.CurrentIndex = currentIndex; 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); var houses = houseSearchResult.result; return(Json(new AjaxResult { Status = "ok", Data = houses })); }
public ActionResult MakeAppointment(HouseAppointmentModel model) { if (!ModelState.IsValid) { string msg = MVCHelper.GetValidMesg(ModelState); return(Json(new AjaxResult { Status = "error", ErrorMsg = msg })); } long?userId = FrontHelper.GetUserId(HttpContext); HouseAppointmentService.AddNew(userId, model.Name, model.PhoneNum, model.HouseId, model.VisitDate); return(Json(new AjaxResult { Status = "ok" })); }
public ActionResult SwitchCityId(long cityId) { long?userId = FrontHelper.GetUserId(this.HttpContext); if (userId == null) { FrontHelper.SetCityId(this.HttpContext, cityId); } else { UserService.SetUserCityId(userId.Value, cityId); } return(Json(new AjaxResult { Status = "ok" })); }
public ActionResult Login(LoginModel login) { //判断用户是否成功登陆 if (UserService.CheckLogin(login.PhoneNum, login.Password)) { //登陆成功后,将用户信息存入session中 var user = UserService.GetByPhoneNum(login.PhoneNum); FrontHelper.SetUserId(this.HttpContext, user.Id); FrontHelper.SetCityId(this.HttpContext, user.CityId); return(Json(new AjaxResult { Status = "ok" })); } return(Json(new AjaxResult { Status = "fail", Msg = "用户名或密码错误!" })); }
public ActionResult SwitchCityId(long cityId) { //将cityId存到数据库user字段中 var userId = FrontHelper.GetUserId(HttpContext); if (userId == null) { HttpContext.Session["CityId"] = cityId; } else { var user = UserService.GetById((long)userId); UserService.SetUserCityId(user.Id, cityId); } return(Json(new AjaxResult() { Status = "ok" })); }