public ActionResult Add(HouseAddModel model) { long? userId = AdminHelper.GetUserId(HttpContext); long? cityId = userService.GetById(userId.Value).CityId; if (cityId == null) { return View("Error", (object)"总部不能进行房源管理"); } HouseAddNewDTO dto = new HouseAddNewDTO(); dto.Address = model.address; dto.Area = model.area; dto.AttachmentIds = model.attachmentIds; dto.CheckInDateTime = model.checkInDateTime; dto.CommunityId = model.CommunityId; dto.DecorateStatusId = model.DecorateStatusId; dto.Description = model.description; dto.Direction = model.direction; dto.FloorIndex = model.floorIndex; dto.LookableDateTime = model.lookableDateTime; dto.MonthRent = model.monthRent; dto.OwnerName = model.ownerName; dto.OwnerPhoneNum = model.ownerPhoneNum; dto.RoomTypeId = model.RoomTypeId; dto.StatusId = model.StatusId; dto.TotalFloorCount = model.totalFloor; dto.TypeId = model.TypeId; houseService.AddNew(dto); return Json(new AjaxResult { Status="ok"}); }
public ActionResult Add(HouseAddModel model) { long?userId = AdminHelper.GetUserId(HttpContext); long?cityId = userSerivce.GetById(userId.Value).CityId; if (cityId == null) { return(View("Error", (object)"总部不能进行房源管理")); } HouseAddnewDTO dto = new HouseAddnewDTO(); dto.Address = model.address; dto.Area = model.area; dto.AttachmentIds = model.attachmentIds; dto.CheckInDateTime = model.checkInDateTime; dto.CommunityId = model.CommunityId; dto.DecorateStatusId = model.DecorateStatusId; dto.Description = model.description; dto.Direction = model.direction; dto.FloorIndex = model.floorIndex; dto.LookableDateTime = model.lookableDateTime; dto.MonthRent = model.monthRent; dto.OwnerName = model.ownerName; dto.OwnerPhoneNum = model.ownerPhoneNum; dto.RoomTypeId = model.RoomTypeId; dto.StatusId = model.StatusId; dto.TotalFloorCount = model.totalFloor; dto.TypeId = model.TypeId; long houseId = houseService.AddNew(dto); //生成房源查看的html文件 CreateStaticPage(houseId); //把房源信息写入ElasticSearch //创建与SQLLite的连接 ElasticConnection client = new ElasticConnection("localhost", 9200); var serializer = new JsonNetSerializer(); //写入数据 //第一个参数相当于“数据库”,第二个参数相当于“表”,第三个参数相当于“主键” IndexCommand indexcmd = new IndexCommand("ZSZHouse", "House", houseId.ToString()); //不用手动创建数据库,es会自动分配空间用zsz命名 //Put()第二个参数是要插入的数据 OperationResult result = client.Put(indexcmd, serializer.Serialize(dto));//把对象序列化成json放入Elastic中返回结果 return(Json(new AjaxResult { Status = "ok" })); }
public ActionResult AddHouse(HouseAddModel model) { long?id = AdminHelper.AdminUserId(HttpContext); long?cityId = AdminUserService.GetById(id.Value).CityId; if (cityId == null) { return(View("ERROR", "总部不能进行房源管理")); } try { HouseAddNewDTO dto = new HouseAddNewDTO(); dto.Address = model.address; dto.Area = model.area; dto.AttachmentIds = model.attachmentIds; dto.CheckInDateTime = model.checkInDateTime; dto.CommunityId = model.CommunityId; dto.DecorateStatusId = model.DecorateStatusId; dto.Description = model.description; dto.Direction = model.direction; dto.FloorIndex = model.floorIndex; dto.LookableDateTime = model.lookableDateTime; dto.MonthRent = model.monthRent; dto.OwnerName = model.ownerName; dto.OwnerPhoneNum = model.ownerPhoneNum; dto.RoomTypeId = model.RoomTypeId; dto.StatusId = model.StatusId; dto.TotalFloorCount = model.totalFloor; dto.TypeId = model.TypeId; long houseId = HouseService.AddNew(dto); return(Json(new AjaxResult <object> { code = 0, msg = "添加成功" })); } catch (Exception ex) { Log.ErrorFormat("添加房源失败:{0}", ex.Message); return(Json(new AjaxResult <string> { code = 1, msg = ex.Message })); } }
public ActionResult Add(HouseAddModel model) { long?userId = AdminHelper.GetUserId(HttpContext); //获得登录用户Id long?cityId = userService.GetById(userId.Value).CityId; //得到该用户所在的城市 if (cityId == null) { return(View("Error", (object)"总部不能进行房源管理")); } HouseAddNewDTO dto = new HouseAddNewDTO(); dto.Address = model.Address; dto.Area = model.Area; dto.AttachmentIds = model.AttachmentIds; dto.CheckInDateTime = model.CheckInDateTime; dto.CommunityId = model.CommunityId; dto.DecorateStatusId = model.DecorateStatusId; dto.Description = model.Description; dto.Direction = model.Direction; dto.FloorIndex = model.FloorIndex; dto.LookableDateTime = model.LookableDateTime; dto.MonthRent = model.MonthRent; dto.OwnerName = model.OwnerName; dto.OwnerPhoneNum = model.OwnerPhoneNum; dto.RoomTypeId = model.RoomTypeId; dto.StatusId = model.StatusId; dto.TotalFloorCount = model.TotalFloorCount; dto.TypeId = model.TypeId; long houseId = houseService.AddNew(dto); //根据新增的房源houseId,生成静态页面 CreateStaticPage(houseId); return(Json(new AjaxResult { Status = "ok", ErrorMsg = "添加房源失败" })); }