public void RegisterQuickTest() { UserService target = CreateNewUserService(); UserRegisterQuickFromDoctorSP p = new UserRegisterQuickFromDoctorSP(); p.FirstName = TestUtils.RandomUtils.RandomString(100); p.LastName = TestUtils.RandomUtils.RandomString(100); p.PhoneNumber = TestUtils.RandomUtils.RandomPhoneNumber(); p.ReferrerUserID = (long)TestEnums.User.constDoctorID; User insertedUser = (User)target.RegisterQuickFromDoctor(p); string phoneNumberSearchable = PhoneNumberUtils.MakeSearchablePhoneNumber(p.PhoneNumber); User u = (User)target.GetByUserNameT(insertedUser.UserName); Assert.AreEqual(insertedUser.UserName.ToLower(), u.UserName, "User name didn't inserted correctly"); //Assert.AreEqual(phoneNumberSearchable, u.PhoneNumberSearchable, "phoneNumber didn't inserted correctly"); UserInRoleService uInRoleService = (UserInRoleService)EntityFactory.GetEntityServiceByName(vUserInRole.EntityName, ""); var count = uInRoleService.GetCount(new FilterExpression(new Filter(vUserInRole.ColumnNames.UserID, u.UserID))); Assert.AreEqual(1, count, "we expect that user be in one of the assigned roles"); // we expect that user be in one of the assigned roles IDoctor_PatientService doctor_PatientService = Doctor_PatientEN.GetService(); FilterExpression filter = new FilterExpression(vDoctor_Patient.ColumnNames.DoctorID, p.ReferrerUserID); filter.AddFilter(vDoctor_Patient.ColumnNames.PatientUserID, u.UserID); Assert.AreEqual(1, doctor_PatientService.GetCount(filter), "Doctor_Patient is not exists."); }
public void RegisterTest() { UserService target = CreateNewUserService(); UserRegisterSP p = new UserRegisterSP(); p.UserName = TestUtils.RandomUtils.RandomUserName(); p.FirstName = TestUtils.RandomUtils.RandomString(100); p.LastName = TestUtils.RandomUtils.RandomString(100); p.Password = TestUtils.RandomUtils.RandomString(64); p.ConfirmPassword = p.Password; p.Email = TestUtils.RandomUtils.RandomEmail(); p.PhoneNumber = TestUtils.RandomUtils.RandomPhoneNumber(); //p.membershipAreaID = 0; p.DefaultRoleID = (long)EntityEnums.RoleEnum.Patient; target.Register(p); User u = (User)target.GetByUserNameT(p.UserName); Assert.AreEqual(p.UserName.ToLower(), u.UserName); Assert.AreEqual(p.Email.ToLower(), u.Email); UserInRoleService uInRoleService = (UserInRoleService)EntityFactory.GetEntityServiceByName(vUserInRole.EntityName, ""); var count = uInRoleService.GetCount(new FilterExpression(new Filter(vUserInRole.ColumnNames.UserID, u.UserID))); Assert.AreEqual(1, count, "UserInRole should have 1 default role"); // we expect that user be in one of the assigned roles TestUtils.Access.SetPrivateStaticField(typeof(FWUtils), "_SecurityUtils", new SecurityUtilsFake(u.UserID)); var ulService = User_LanguageEN.GetService(); var count2 = uInRoleService.GetCount(new FilterExpression(new Filter(vUser_Language.ColumnNames.UserID, u.UserID))); Assert.AreEqual(1, count2, "User_Language should have 1 default language"); // we expect that user be in one of the assigned roles }
/// <summary> /// 给用户添加角色 /// </summary> /// <param name="userId"></param> /// <param name="roleId"></param> public void CreateUserInRole(int userId, int roleId) { UserInRoleService sve = new UserInRoleService(); sve.Create(new UserInRole { RoleId = roleId, UserId = userId }); }
/// <summary> /// 删除当前用户的全部角色 /// </summary> /// <param name="userId"></param> public void RemoveUserInRole(int userId) { UserInRoleService sve = new UserInRoleService(); sve.RemoveUserId(userId); }
/// <summary> /// 删除管理员与权限关系 /// </summary> /// <param name="id"></param> public void UserInRolesRemove(long id) { UserInRoleService sve = new UserInRoleService(); sve.Remove(id); }
/// <summary> /// 获取特定用户的角色列表 /// </summary> /// <param name="id"></param> /// <returns></returns> public List <UserInRole> GetUserInRolesByUserId(long id) { UserInRoleService svc = new UserInRoleService(); return(svc.UserInRolesWhereManagerId(id)); }
/// <summary> /// 全部管理员与权限关系表 /// </summary> /// <returns></returns> public List <UserInRole> GetAllUserInRoles() { UserInRoleService sve = new UserInRoleService(); return(sve.GetAll()); }
public UserInRolesController() { _userInRoleService = new UserInRoleService(); }