/// <summary> /// 删除小区 /// </summary> /// <param name="id">小区ID</param> /// <returns></returns> public JsonModel DelPlace(int id) { JsonModel jm = new JsonModel(); //获取指定ID且未删除的小区 IPropertyPlaceBLL placeBll = BLLFactory <IPropertyPlaceBLL> .GetBLL("PropertyPlaceBLL"); T_PropertyPlace place = placeBll.GetEntity(m => m.Id == id && m.DelFlag == ConstantParam.DEL_FLAG_DEFAULT); //如果该小区存在 if (place == null) { jm.Msg = "该物业小区不存在"; } else { place.DelFlag = ConstantParam.DEL_FLAG_DELETE; if (placeBll.DeletePlace(place)) { //操作日志 jm.Content = "删除物业小区 " + place.Name; } else { jm.Msg = "删除失败"; } } return(jm); }
/// <summary> /// 初始化小区编辑模型 /// </summary> public PropertyPlaceModel InitPlaceEditModel(T_PropertyPlace place) { //创建物业小区模型并赋值 PropertyPlaceModel model = new PropertyPlaceModel() { PlaceId = place.Id, PlaceName = place.Name, CompanyId = place.CompanyId, ProvinceId = place.ProvinceId, ProvinceList = GetProvinceList(), CityId = place.CityId, CityList = base.GetCityList(place.ProvinceId), CountyId = place.CountyId, CountyList = base.GetCountyList(place.CityId), Address = place.Address, Longitude = place.Longitude, Latitude = place.Latitude, Tel = place.Tel, Content = place.Content, PlaceType = place.PlaceType, PlaceTypeList = GetPlaceTypeList(place.PlaceType), IsValidate = place.IsValidate == 0 }; return(model); }
/// <summary> /// 获取验证状态 /// </summary> /// <param name="Place">要验证的小区</param> /// <param name="User">注册用户</param> /// <returns>-1:未申请 0:审核中 1:已通过 2:已驳回</returns> private int GetVerifyStatus(T_PropertyPlace Place, T_User User) { //如果是住宅小区 if (Place.PlaceType == ConstantParam.PLACE_TYPE_HOUSE) { var IdentityVerification = User.PropertyIdentityVerification.Where(v => v.DoorId != null && v.BuildDoor.BuildUnit.Build.PropertyPlaceId == Place.Id).FirstOrDefault(); if (IdentityVerification == null) { return(-1); } else { return(IdentityVerification.IsVerified); } } else { var IdentityVerification = User.PropertyIdentityVerification.Where(v => v.BuildCompanyId != null && v.BuildCompany.PropertyPlaceId == Place.Id).FirstOrDefault(); if (IdentityVerification == null) { return(-1); } else { return(IdentityVerification.IsVerified); } } }
/// <summary> /// 编辑小区信息 /// </summary> public JsonModel EditPlace(PropertyPlaceModel model) { JsonModel jm = new JsonModel(); //如果表单模型验证成功 if (ModelState.IsValid) { IPropertyCompanyBLL companyBll = BLLFactory <IPropertyCompanyBLL> .GetBLL("PropertyCompanyBLL"); //如果对应的公司不存在(被删除) if (!companyBll.Exist(c => c.Id == model.CompanyId && c.DelFlag == ConstantParam.DEL_FLAG_DEFAULT)) { jm.Msg = "当前物业总公司不存在"; } else { //获取指定ID且未删除的小区 IPropertyPlaceBLL placeBll = BLLFactory <IPropertyPlaceBLL> .GetBLL("PropertyPlaceBLL"); T_PropertyPlace place = placeBll.GetEntity(m => m.Id == model.PlaceId && m.DelFlag == ConstantParam.DEL_FLAG_DEFAULT); if (place != null) { //重新给数据实体赋值 place.Name = model.PlaceName; place.CompanyId = model.CompanyId; place.ProvinceId = model.ProvinceId; place.CityId = model.CityId; place.CountyId = model.CountyId; place.Address = model.Address; place.Longitude = model.Longitude; place.Latitude = model.Latitude; place.Tel = model.Tel; place.Content = model.Content; place.PlaceType = model.PlaceType; place.IsValidate = model.IsValidate ? 0 : 1; //编辑 if (placeBll.Update(place)) { //日志记录 jm.Content = PropertyUtils.ModelToJsonString(model); } else { jm.Msg = "编辑失败"; } } else { jm.Msg = "该物业小区不存在"; } } } else { jm.Msg = ConstantParam.JSON_RESULT_MODEL_CHECK_ERROR; } return(jm); }
/// <summary> /// 添加小区 /// </summary> public JsonModel AddPlace(PropertyPlaceModel model) { JsonModel jm = new JsonModel(); //如果表单模型验证成功 if (ModelState.IsValid) { IPropertyCompanyBLL companyBll = BLLFactory <IPropertyCompanyBLL> .GetBLL("PropertyCompanyBLL"); //如果对应的公司不存在(被删除) if (!companyBll.Exist(c => c.Id == model.CompanyId && c.DelFlag == ConstantParam.DEL_FLAG_DEFAULT)) { jm.Msg = "物业总公司不存在"; } else { IPropertyPlaceBLL placeBll = BLLFactory <IPropertyPlaceBLL> .GetBLL("PropertyPlaceBLL"); T_PropertyPlace place = new T_PropertyPlace() { Name = model.PlaceName, CompanyId = model.CompanyId, ProvinceId = model.ProvinceId, CityId = model.CityId, CountyId = model.CountyId, Address = model.Address, Longitude = model.Longitude, Latitude = model.Latitude, Tel = model.Tel, Content = model.Content, PlaceType = model.PlaceType, IsValidate = model.IsValidate ? 0 : 1 }; //添加小区并指定系统角色 placeBll.AddPlace(place); //日志记录 jm.Content = PropertyUtils.ModelToJsonString(model); } } else { jm.Msg = ConstantParam.JSON_RESULT_MODEL_CHECK_ERROR; } return(jm); }
public ActionResult PlaceDetail(int id) { //获取要查看详细的小区 IPropertyPlaceBLL placeBll = BLLFactory <IPropertyPlaceBLL> .GetBLL("PropertyPlaceBLL"); T_PropertyPlace place = placeBll.GetEntity(m => m.Id == id && m.DelFlag == ConstantParam.DEL_FLAG_DEFAULT); if (place != null) { //如果存在,将数据传递到页面 return(View(place)); } else { //如果不存在,则回到小区列表页 return(RedirectToAction("PlaceList")); } }
public ActionResult EditPlace(int id) { //获取指定ID且未删除的小区 IPropertyPlaceBLL placeBll = BLLFactory <IPropertyPlaceBLL> .GetBLL("PropertyPlaceBLL"); T_PropertyPlace place = placeBll.GetEntity(m => m.Id == id && m.DelFlag == ConstantParam.DEL_FLAG_DEFAULT); //如果该小区存在 if (place != null) { //初始化小区模型 var model = InitPlaceEditModel(place); //将模型传给页面 return(View(model)); } else { return(RedirectToAction("PlaceList")); } }
public ActionResult UploadImg(int id) { IPropertyPlaceBLL propertyPlaceBll = BLLFactory <IPropertyPlaceBLL> .GetBLL("PropertyPlaceBLL"); T_PropertyPlace place = propertyPlaceBll.GetEntity(m => m.DelFlag == ConstantParam.DEL_FLAG_DEFAULT && m.Id == id); //物业小区存在 if (place != null) { PropertyPlaceModel model = new PropertyPlaceModel() { PlaceId = place.Id, Img = place.Img }; return(View(model)); } else { return(RedirectToAction("PlaceList")); } }
public ActionResult SetAdministrator(int id) { //获取要设置管理员的小区 IPropertyPlaceBLL placeBll = BLLFactory <IPropertyPlaceBLL> .GetBLL("PropertyPlaceBLL"); T_PropertyPlace place = placeBll.GetEntity(m => m.Id == id && m.DelFlag == ConstantParam.DEL_FLAG_DEFAULT); //如果该小区存在 if (place != null) { //初始化返回页面的模型 PropertyUserModel model = new PropertyUserModel(); model.PlaceId = place.Id; model.PlaceName = place.Name; ViewBag.Admins = place.PropertyUsers.Where(u => u.IsMgr == ConstantParam.USER_ROLE_MGR).Select(u => u.UserName).ToList(); return(View(model)); } else { return(RedirectToAction("PlaceList")); } }
/// <summary> /// 上传小区图标 /// </summary> /// <param name="data">图片数据</param> /// <param name="id">小区ID</param> /// <returns></returns> public JsonModel UploadPlaceImg(string data, int id) { JsonModel jm = new JsonModel(); string directory = Server.MapPath(ConstantParam.PROPERTY_PLACE_DIR); if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } var fileName = DateTime.Now.ToFileTime().ToString() + ".jpg"; var path = Path.Combine(directory, fileName); using (FileStream fs = new FileStream(path, FileMode.Create))//使用指定的路径初始化实例 { using (BinaryWriter bw = new BinaryWriter(fs)) { byte[] datas = Convert.FromBase64String(data); bw.Write(datas); bw.Close(); } } if (!Directory.Exists(Server.MapPath(ConstantParam.PROPERTY_PLACE_ThumIMG_DIR))) { Directory.CreateDirectory(Server.MapPath(ConstantParam.PROPERTY_PLACE_ThumIMG_DIR)); } //生成缩略图 string thumpFile = DateTime.Now.ToFileTime() + ".jpg"; var thumpPath = Path.Combine(Server.MapPath(ConstantParam.PROPERTY_PLACE_ThumIMG_DIR), thumpFile); PropertyUtils.getThumImage(path, 18, 3, thumpPath); IPropertyPlaceBLL propertyPlaceBll = BLLFactory <IPropertyPlaceBLL> .GetBLL("PropertyPlaceBLL"); T_PropertyPlace place = propertyPlaceBll.GetEntity(m => m.DelFlag == ConstantParam.DEL_FLAG_DEFAULT && m.Id == id); //物业小区存在 if (place != null) { string oldFile = place.Img; string oldThumFile = place.ImgThumbnail; place.Img = ConstantParam.PROPERTY_PLACE_DIR + fileName; place.ImgThumbnail = ConstantParam.PROPERTY_PLACE_ThumIMG_DIR + thumpFile; if (propertyPlaceBll.Update(place)) { //删除旧图标 if (!string.IsNullOrEmpty(oldFile)) { //FileInfo f = new FileInfo(Server.MapPath(oldFile)); //if (f.Exists) // f.Delete(); } //删除旧缩略图标 if (!string.IsNullOrEmpty(oldThumFile)) { FileInfo m = new FileInfo(Server.MapPath(oldThumFile)); if (m.Exists) { m.Delete(); } } } } //物业小区不存在 else { jm.Msg = "物业小区不存在"; } return(jm); }