public JsonResult AddRole(RoleModel model) { JsonModel jm = new JsonModel(); //如果表单模型验证成功 if (ModelState.IsValid) { IPropertyRoleBLL propertyRoleBll = BLLFactory <IPropertyRoleBLL> .GetBLL("PropertyRoleBLL"); //初始化平台角色数据实体 T_PropertyRole role = new T_PropertyRole() { RoleName = model.RoleName, RoleMemo = model.RoleMemo, PropertyPlaceId = GetSessionModel().PropertyPlaceId.Value }; //保存 propertyRoleBll.Save(role); //日志记录 jm.Content = PropertyUtils.ModelToJsonString(model); } else { jm.Msg = ConstantParam.JSON_RESULT_MODEL_CHECK_ERROR; } return(Json(jm, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 添加小区,指定系统角色 /// </summary> /// <param name="place">小区实体对象</param> /// <returns></returns> public bool AddPlace(T_PropertyPlace place) { //使用事务进行数据库操作 using (var tran = this.nContext.Database.BeginTransaction()) { try { //添加小区 var newPlace = base.Save(place); if (newPlace != null) { //给小区设定系统角色 IPropertyRoleBLL propertyRoleBll = BLLFactory <IPropertyRoleBLL> .GetBLL("PropertyRoleBLL"); //初始化物业系统角色数据实体 T_PropertyRole role = new T_PropertyRole() { RoleName = ConstantParam.SYSTEM_ROLE_NAME, RoleMemo = ConstantParam.SYSTEM_ROLE_MEMO, PropertyPlaceId = newPlace.Id, IsSystem = ConstantParam.USER_ROLE_MGR }; //保存 propertyRoleBll.Save(role); //提交事务 tran.Commit(); } } catch { tran.Rollback(); return(false); } } return(true); }