private void Awake() { role = GetComponent <Role>(); r2d = GetComponent <Rigidbody2D>(); rc = GetComponent <RoleController>(); vo = role.vo; }
public void EditRoleTest() { #region arrange RoleVO roleVO = new RoleVO() { RoleName = "Admin", Description = "最高權限" }; int reNumber = 1; _dataAccess.Stub(o => o.ExcuteSQL(Arg <string> .Is.Anything, Arg <object[]> .Is.Anything)).Return(reNumber); #endregion #region act var result = _target.EditRole(roleVO); #endregion #region assert Assert.AreEqual(result, reNumber); #endregion }
public Status delete(List <int> roleIDs) { if (roleIDs.Count == 0) { return(Status.SUCCESS); } RoleDAO roleDao = Factory.getInstance <RoleDAO>(); Role_PermissionDAO role_PermissionDao = Factory.getInstance <Role_PermissionDAO>(); Dictionary <string, object> wherelist = new Dictionary <string, object>(); foreach (int roleID in roleIDs) { //获取角色信息 RoleVO roleVo = roleDao.getOne <RoleVO>(roleID); if (roleVo.isIntegrant)//禁止删除系统角色 { return(Status.PERMISSION_DENIED); } wherelist.Clear(); wherelist.Add("roleID", roleID); role_PermissionDao.delete(wherelist); } return(Status.SUCCESS); }
public void AddRoleTest() { #region arrange (測試成功) RoleVO roleVO = new RoleVO() { RoleName = "Admin", Description = "最高權限" }; int reNumber = 1; string reMessage = ""; _roleEfRepo.Stub(o => o.AddRole(Arg <RoleVO> .Is.Anything)).Return(reNumber); #endregion #region act var result = _target.AddRole(roleVO); #endregion #region assert Assert.AreEqual(result, reMessage); #endregion }
public void EditRoleTest1() { #region arrange (編輯失敗) RoleVO roleVO = new RoleVO() { RoleID = 1, RoleName = "Admin", Description = "最高權限" }; int reNumber = -1; string reMessage = "編輯失敗。"; _roleRepo.Stub(o => o.EditRole(Arg <RoleVO> .Is.Anything)).Return(reNumber); #endregion #region act var result = _target.EditRole(roleVO); #endregion #region assert Assert.AreEqual(result, reMessage); #endregion }
public string NoSelectSaveRoleUserSetting(RoleVO roleVO) { string result = string.Empty; //處理清空所有check時的行為 result = _roleService.ClearRoleUserByRoleID(roleVO.RoleID.ToString()); return(result); }
/// <summary> /// 編輯角色 /// </summary> /// <param name="roleVO"></param> /// <returns></returns> public int EditRole(RoleVO roleVO) { var roleData = _db.Role.Where(o => o.RoleID == roleVO.RoleID).FirstOrDefault(); roleData.RoleName = roleVO.RoleName; roleData.Description = roleVO.Description; Update(roleData); return(SaveChanges()); }
/// <summary> /// 新增角色 /// </summary> /// <param name="roleVO"></param> /// <returns></returns> public int AddRole(RoleVO roleVO) { Insert(new Role() { RoleName = roleVO.RoleName, Description = roleVO.Description }); return(SaveChanges()); }
public IEnumerable <FunctionCheckVO> GetFunctionByRole(RoleVO roleVO) { PageDataVO pageDataVO = new PageDataVO() { OrderByColumn = "FunctionID", OrderByType = "ASC" }; var functionCheckData = _functionService.GetFunctionCheckByRole(roleVO.RoleID.ToString(), pageDataVO); return(functionCheckData); }
/// <summary> /// 新增角色 /// </summary> /// <param name="roleVO"></param> /// <returns></returns> public int AddRole(RoleVO roleVO) { List <string> param = new List <string>(); string sqlStr = @"Insert Into [Role] (RoleName,Description) Values(@p0,@p1) "; param.Add(roleVO.RoleName); param.Add(roleVO.Description); return(_dataAccess.ExcuteSQL(sqlStr, param.ToArray())); }
public IEnumerable <UserCheckVO> GetUserByRole(RoleVO roleVO) { PageDataVO pageDataVO = new PageDataVO() { OrderByColumn = "UserID", OrderByType = "ASC" }; var userCheckData = _roleService.GetUserCheckByRole(roleVO.RoleID.ToString(), pageDataVO); return(userCheckData); }
/// <summary> /// 編輯角色 /// </summary> /// <param name="roleVO"></param> /// <returns></returns> public string EditRole(RoleVO roleVO) { int result = _roleRepo.EditRole(roleVO); if (result > 0) { return(""); } else { return("編輯失敗。"); } }
/// <summary> /// 新增角色 /// </summary> /// <param name="roleVO"></param> /// <returns></returns> public string AddRole(RoleVO roleVO) { int result = _roleRepo.AddRole(roleVO); if (result > 0) { return(""); } else { return("新增失敗。"); } }
/// <summary> /// 編輯角色 /// </summary> /// <param name="roleVO"></param> /// <returns></returns> public int EditRole(RoleVO roleVO) { List <string> param = new List <string>(); string sqlStr = @"Update [Role] Set RoleName = @p0 , Description = @p1 Where RoleID = @p2 "; param.Add(roleVO.RoleName); param.Add(roleVO.Description); param.Add(roleVO.RoleID.ToString()); return(_dataAccess.ExcuteSQL(sqlStr, param.ToArray())); }
public RoleVO FindAdminRole(RoleContext ctx) { RoleVO role = null; try { role = ctx.Role.Where(s => s.Name == "Admin").SingleOrDefault(); } catch { throw; } return(role); }
public override void HandleNotification(INotification note) { UserVO user; RoleVO role; string userName; switch (note.Name) { case NotiConst.NEW_USER: RolePanel.ClearForm(); break; case NotiConst.USER_ADDED: user = (UserVO)note.Body; userName = user == null ? "" : user.UserName; role = new RoleVO(userName); roleProxy.AddItem(role); RolePanel.ClearForm(); break; case NotiConst.USER_UPDATED: RolePanel.ClearForm(); break; case NotiConst.USER_DELETED: RolePanel.ClearForm(); break; case NotiConst.CANCEL_SELECTED: RolePanel.ClearForm(); break; case NotiConst.USER_SELECTED: user = (UserVO)note.Body; userName = user == null ? "" : user.UserName; RolePanel.ShowUser(user, roleProxy.GetUserRoles(userName)); break; case NotiConst.ADD_ROLE: userName = RolePanel.User == null ? "" : RolePanel.User.UserName; RolePanel.ShowUserRoles(roleProxy.GetUserRoles(userName)); break; case NotiConst.DEL_ROLE: userName = RolePanel.User == null ? "" : RolePanel.User.UserName; RolePanel.ShowUserRoles(roleProxy.GetUserRoles(userName)); break; } }
public ActionResult EditRole(RoleVO roleVO) { var result = _roleService.EditRole(roleVO); if (!string.IsNullOrEmpty(result)) { CurrentHttpContext.Response.StatusCode = (int)HttpStatusCode.BadRequest; return(Json(result, JsonRequestBehavior.AllowGet)); } else { CurrentHttpContext.Response.StatusCode = (int)HttpStatusCode.OK; } return(Json(result, JsonRequestBehavior.AllowGet)); }
public RoleVO GetRoleById(int id) { RoleVO model = new RoleVO(); try { using (var ctx = new RoleContext()) { IRoleDA da = new RoleDA(); model = da.FindRoleById(ctx, id); } }catch { throw; } return(model); }
public RoleVO AddRole(RoleVO roleVO) { if (!ModelState.IsValid) { roleVO.Message = "請填寫必填欄位"; } else { var result = _roleService.AddRole(roleVO); if (!string.IsNullOrEmpty(result)) { roleVO.Message = result; } } return(roleVO); }
public RoleVO FindRoleById(RoleContext ctx, int id) { RoleVO role = new RoleVO(); try { var query = (from r in ctx.Role where r.Id == id select new { r.Name }).Single(); role.Id = id; role.Name = FillItemForDatabase.FillItem(query.Name); } catch { throw; } return(role); }
public void AddRoleTest1() { #region arrange (新增失敗) // httpContext物件設定 var httpContext = FakeHttpContextManager.CreateHttpContextBase(); httpContext.Response.StatusCode = 200; // 傳入新增的腳色 RoleVO roleVO = new RoleVO() { RoleName = "Admin", Description = "最高權限" }; // 回傳新增後的腳色 string reMessage = "新增失敗。"; _roleService.Stub(o => o.AddRole(Arg <RoleVO> .Is.Anything)).Return(reMessage); // 設定httpContext _target.CurrentHttpContext = httpContext; #endregion #region act var resultData = _target.AddRole(roleVO); var result = (RoleVO)(((JsonResult)resultData).Data); #endregion #region assert // 測試回應狀態 Assert.AreEqual(_target.CurrentHttpContext.Response.StatusCode, 400); // 測試回傳結果 Assert.AreEqual(result.RoleName, "Admin"); Assert.AreEqual(result.Description, "最高權限"); Assert.AreEqual(result.Message, "新增失敗。"); #endregion }
public void EditRoleTest1() { #region arrange (編輯失敗) // httpContext物件設定 var httpContext = FakeHttpContextManager.CreateHttpContextBase(); httpContext.Response.StatusCode = 200; // 設定httpContext _target.CurrentHttpContext = httpContext; RoleVO roleVO = new RoleVO() { RoleID = 1, RoleName = "Admin", Description = "最高權限" }; string reMessage = "編輯失敗。"; _roleService.Stub(o => o.EditRole(Arg <RoleVO> .Is.Anything)).Return(reMessage); #endregion #region act var resultData = _target.EditRole(roleVO); var result = (string)((JsonResult)resultData).Data; #endregion #region assert // 測試回應狀態 Assert.AreEqual(_target.CurrentHttpContext.Response.StatusCode, 400); Assert.AreEqual(result, reMessage); #endregion }
public ActionResult AddRole(RoleVO roleVO) { if (!ModelState.IsValid) { CurrentHttpContext.Response.StatusCode = (int)HttpStatusCode.BadRequest; roleVO.Message = "請填寫必填欄位"; } else { var result = _roleService.AddRole(roleVO); if (!string.IsNullOrEmpty(result)) { CurrentHttpContext.Response.StatusCode = (int)HttpStatusCode.BadRequest; roleVO.Message = result; } else { CurrentHttpContext.Response.StatusCode = (int)HttpStatusCode.OK; } } return(Json(roleVO, JsonRequestBehavior.AllowGet)); }
public void AddRoleTest1() { #region arrange (新增失敗) RoleVO roleVO = new RoleVO() { RoleName = "Admin", Description = "最高權限" }; string reMessage = "新增失敗。"; _roleBO.Stub(o => o.AddRole(Arg<RoleVO>.Is.Anything)).Return(reMessage); #endregion #region act var result = _target.AddRole(roleVO); #endregion #region assert Assert.AreEqual(result, reMessage); #endregion }
public string EditRole(RoleVO roleVO) { var result = _roleService.EditRole(roleVO); return(result); }
public string DeleteRole(RoleVO roleVO) { var result = _roleService.DeleteRole(roleVO.RoleID.ToString()); return(result); }
/// <summary> /// add an item to the data /// </summary> /// <param name="role"></param> public void AddItem(RoleVO role) { Roles.Add(role); }
private void GetDatabaseUserRolesPermissions() { Dictionary <string, object> wherelist = new Dictionary <string, object>(); //根据用户名从数据库中填充角色列表和权限列表 PersonDAO personDao = Factory.getInstance <PersonDAO>(); wherelist.Add("personName", this.userName); PersonVO personVo = personDao.getOne <PersonVO>(wherelist); if (personVo == null) { return; } this.userID = personVo.personID; Person_RoleDAO person_roleDao = Factory.getInstance <Person_RoleDAO>(); wherelist.Clear(); wherelist.Add("personID", userID); //获取用户、角色关联 List <Person_RoleVO> person_roleVolist = person_roleDao.getAll <Person_RoleVO>(wherelist); if (person_roleVolist == null) { return; } foreach (Person_RoleVO person_roleVo in person_roleVolist) { UserRole userRole = new UserRole(); userRole.roleID = person_roleVo.roleID; RoleDAO roleDAO = Factory.getInstance <RoleDAO>(); //获取角色信息 RoleVO roleVo = roleDAO.getOne <RoleVO>(userRole.roleID); if (roleVo == null) { continue; } userRole.roleID = roleVo.roleID; userRole.roleName = roleVo.roleName; Role_PermissionDAO rolePermissionDAO = Factory.getInstance <Role_PermissionDAO>(); wherelist.Clear(); wherelist.Add("roleID", roleVo.roleID); //获取角色、权限关联 List <Role_PermissionVO> role_permissionVolist = rolePermissionDAO.getAll <Role_PermissionVO>(wherelist); if (role_permissionVolist == null) { continue; } foreach (Role_PermissionVO role_permissionVo in role_permissionVolist) { RolePermission rolePermission = new RolePermission(); rolePermission.permissionID = role_permissionVo.permissionID; PermissionDAO permissionDAO = Factory.getInstance <PermissionDAO>(); //获取权限信息 PermissionVO permissionVo = permissionDAO.getOne <PermissionVO>(role_permissionVo.permissionID); if (permissionVo == null) { continue; } rolePermission.PermissionDescription = permissionVo.permissionDescription; userRole.permissions.Add(rolePermission); } roles.Add(userRole); } }
/// <summary> /// 新增角色 /// </summary> /// <param name="roleVO"></param> /// <returns></returns> public string AddRole(RoleVO roleVO) { return(_roleBO.AddRole(roleVO)); }
/// <summary> /// 編輯角色 /// </summary> /// <param name="roleVO"></param> /// <returns></returns> public string EditRole(RoleVO roleVO) { return(_roleBO.EditRole(roleVO)); }