예제 #1
0
파일: Role.cs 프로젝트: kneeclass/brickpile
 public Role(string name, Role parentRole)
 {
     this.Name = name;
     if (parentRole != null)
     {
         this.ParentRoleId = parentRole.Id;
     }
 }
예제 #2
0
        /// <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;
                }
            }
        }