public ActionResult AddUser(PropertyUserModel model) { JsonModel jm = new JsonModel(); //如果表单模型验证成功 if (ModelState.IsValid) { IPropertyUserBLL propertyUserBll = BLLFactory <IPropertyUserBLL> .GetBLL("PropertyUserBLL"); T_PropertyUser propertyUser = new T_PropertyUser() { UserName = model.UserName, TrueName = model.TrueName, Password = PropertyUtils.GetMD5Str(model.Password), Memo = model.Memo, Tel = model.Tel, Phone = model.Phone, Email = model.Email, PropertyPlaceId = GetSessionModel().PropertyPlaceId.Value }; // 保存到数据库 propertyUserBll.Save(propertyUser); //日志记录 jm.Content = PropertyUtils.ModelToJsonString(model); } else { // 保存异常日志 jm.Msg = ConstantParam.JSON_RESULT_MODEL_CHECK_ERROR; } return(Json(jm, JsonRequestBehavior.AllowGet)); }
public ActionResult AddUser() { // 获取物业管理员所属的物业小区 int placeId = GetSessionModel().PropertyPlaceId.Value; // 获取指定小区的名称 IPropertyPlaceBLL propertyPlaceBll = BLLFactory <IPropertyPlaceBLL> .GetBLL("PropertyPlaceBLL"); var place = propertyPlaceBll.GetEntity(m => m.Id == placeId); if (place != null) { PropertyUserModel model = new PropertyUserModel() { PlaceName = place.Name }; return(View(model)); } return(View()); }
/// <summary> /// 设置管理员提交 /// </summary> /// <param name="model"></param> /// <returns></returns> public JsonModel SetAdmin(PropertyUserModel model) { JsonModel jm = new JsonModel(); //如果表单模型验证成功 if (ModelState.IsValid) { IPropertyUserBLL propertyUserBll = BLLFactory <IPropertyUserBLL> .GetBLL("PropertyUserBLL"); T_PropertyUser propertyUser = new T_PropertyUser() { PropertyPlaceId = model.PlaceId, UserName = model.UserName, Email = model.Email, Password = PropertyUtils.GetMD5Str(model.Password), IsMgr = ConstantParam.USER_ROLE_MGR, DelFlag = ConstantParam.DEL_FLAG_DEFAULT, }; //为管理员添加角色 IPropertyRoleBLL roleBll = BLLFactory <IPropertyRoleBLL> .GetBLL("PropertyRoleBLL"); var role = roleBll.GetEntity(r => r.IsSystem == ConstantParam.USER_ROLE_MGR && r.PropertyPlaceId == model.PlaceId); if (role != null) { propertyUser.PropertyUserRoles.Add(new R_PropertyUserRole() { RoleId = role.Id, }); } //创建管理员 propertyUserBll.Save(propertyUser); //日志记录 jm.Content = PropertyUtils.ModelToJsonString(model); } else { jm.Msg = ConstantParam.JSON_RESULT_MODEL_CHECK_ERROR; } return(jm); }
public ActionResult EditUser(int?id) { // 参数校验 if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } IPropertyUserBLL propertyUserBll = BLLFactory <IPropertyUserBLL> .GetBLL("PropertyUserBLL"); var userInfo = propertyUserBll.GetEntity(index => index.Id == id && index.DelFlag == ConstantParam.DEL_FLAG_DEFAULT); if (userInfo != null) { PropertyUserModel propertyUserModel = new PropertyUserModel(); propertyUserModel.UserId = userInfo.Id; propertyUserModel.UserName = userInfo.UserName; propertyUserModel.TrueName = userInfo.TrueName; propertyUserModel.Memo = userInfo.Memo; propertyUserModel.Tel = userInfo.Tel; propertyUserModel.Phone = userInfo.Phone; propertyUserModel.Email = userInfo.Email; propertyUserModel.HeadPath = userInfo.HeadPath; propertyUserModel.PlaceId = GetSessionModel().PropertyPlaceId.Value; // 获取指定小区的名称 IPropertyPlaceBLL propertyPlaceBll = BLLFactory <IPropertyPlaceBLL> .GetBLL("PropertyPlaceBLL"); var place = propertyPlaceBll.GetEntity(m => m.Id == propertyUserModel.PlaceId); if (place != null) { propertyUserModel.PlaceName = place.Name; } return(View(propertyUserModel)); } else { return(RedirectToAction("UserList")); } }
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")); } }
public ActionResult EditUser(PropertyUserModel model) { JsonModel jm = new JsonModel(); //如果表单模型验证成功 if (ModelState.IsValid) { IPropertyUserBLL propertyUserBll = BLLFactory <IPropertyUserBLL> .GetBLL("PropertyUserBLL"); T_PropertyUser propertyUser = propertyUserBll.GetEntity(m => m.Id == model.UserId && m.DelFlag == ConstantParam.DEL_FLAG_DEFAULT); if (propertyUser != null) { propertyUser.UserName = model.UserName; propertyUser.TrueName = model.TrueName; propertyUser.Memo = model.Memo; propertyUser.Tel = model.Tel; propertyUser.Phone = model.Phone; propertyUser.Email = model.Email; // 保存到数据库 propertyUserBll.Update(propertyUser); //日志记录 jm.Content = PropertyUtils.ModelToJsonString(model); } else { jm.Msg = "该用户不存在"; } } else { // 保存异常日志 jm.Msg = ConstantParam.JSON_RESULT_MODEL_CHECK_ERROR; } return(Json(jm, JsonRequestBehavior.AllowGet)); }
public ActionResult UploadPic(int id) { JsonModel jm = new JsonModel(); IPropertyUserBLL UserBll = BLLFactory <IPropertyUserBLL> .GetBLL("PropertyUserBLL"); var user = UserBll.GetEntity(m => m.DelFlag == 0 && m.Id == id); //用户存在 if (user != null) { PropertyUserModel userModel = new PropertyUserModel() { UserId = user.Id, HeadPath = user.HeadPath }; return(View(userModel)); } //用户不存在 else { jm.Msg = "用户不存在"; } return(Json(jm, JsonRequestBehavior.AllowGet)); }
public JsonResult SetAdministrator(PropertyUserModel model) { var jm = base.SetAdmin(model); return(Json(jm, JsonRequestBehavior.AllowGet)); }