/// <summary> /// Add System User as a Member of a SystemUserGroup /// </summary> /// <param name="user"></param> /// <param name="group"></param> public static void AddSystemUserToSystemUserGroup(Simplified.Ring3.SystemUser user, Simplified.Ring3.SystemUserGroup group) { Simplified.Ring3.SystemUserGroupMember systemUserGroupMember = new Simplified.Ring3.SystemUserGroupMember(); systemUserGroupMember.WhatIs = user; systemUserGroupMember.ToWhat = group; //systemUserGroupMember.SetSystemUser(user); //systemUserGroupMember.SetToWhat(group); //group.AddMember(systemUser); }
void Handle(Input.AddUserToGroup action) { if (string.IsNullOrEmpty(this.SelectedSystemUserGroupID_)) { action.Cancel(); // TODO: Feedback! return; } Simplified.Ring3.SystemUserGroup group = Db.SQL <Simplified.Ring3.SystemUserGroup>("SELECT o FROM Simplified.Ring3.SystemUserGroup o WHERE o.ObjectID=?", this.SelectedSystemUserGroupID_).First; Simplified.Ring3.SystemUserGroupMember systemUserGroupMember = new Simplified.Ring3.SystemUserGroupMember(); systemUserGroupMember.WhatIs = this.Data as Simplified.Ring3.SystemUser; systemUserGroupMember.ToWhat = group; this.SelectedSystemUserGroupID_ = null; }
/// <summary> /// Assure that there is at least one system user beloning to the admin group /// </summary> internal static void AssureAdminSystemUser() { SystemUserGroup group = Db.SQL <SystemUserGroup>("SELECT o FROM Simplified.Ring3.SystemUserGroup o WHERE o.Name = ?", AdminGroupName).First; SystemUser user = Db.SQL <SystemUser>("SELECT o FROM Simplified.Ring3.SystemUser o WHERE o.Username = ?", AdminUsername) .First; if (group != null && user != null && SystemUser.IsMemberOfGroup(user, group)) { return; } // There is no system user beloning to the admin group Db.Transact(() => { if (group == null) { group = new SystemUserGroup(); group.Name = AdminGroupName; group.Description = AdminGroupDescription; } if (user == null) { Person person = new Person() { FirstName = AdminUsername, LastName = AdminUsername }; user = SystemUser.RegisterSystemUser(AdminUsername, AdminEmail, AdminPassword); user.WhatIs = person; } // Add the admin group to the system admin user SystemUserGroupMember member = new Simplified.Ring3.SystemUserGroupMember(); member.WhatIs = user; member.ToWhat = group; }); }
public static void AddUserToGroup(SystemUser User, SystemUserGroup Group) { if (User == null) { throw new ArgumentNullException("User"); } if (Group == null) { throw new ArgumentNullException("Group"); } if (IsMemberOfGroup(User, Group)) { return; } SystemUserGroupMember member = new SystemUserGroupMember() { SystemUser = User, SystemUserGroup = Group }; }