public Role(string name, Role parentRole) { this.Name = name; if (parentRole != null) { this.ParentRoleId = parentRole.Id; } }
/// <summary> /// Adds a new role to the data source for the configured applicationName. /// </summary> /// <param name="roleName">The name of the role to create.</param> public override void CreateRole(string roleName) { using (var session = this.DocumentStore.OpenSession()) { try { var role = new Role(roleName, null); role.ApplicationName = this.ApplicationName; session.Store(role); session.SaveChanges(); } catch (Exception ex) { // TODO: log exception properly Console.WriteLine(ex.ToString()); throw; } } }