Exemple #1
0
        public void UpdateRole()
        {
            var db   = new Data.SecurityEntities();
            var role = Data.Role.GetRole(CreatedRoleTextBox.Text, db);

            role.ApplicationId   = new Guid(ApplicationIdTextBox.Text);
            role.Description     = DescriptionTextBox.Text;
            role.LoweredRoleName = RoleNameTextBox.Text.ToLower();
            role.RoleName        = RoleNameTextBox.Text;
            db.SaveChanges();
            RiseUpdated(new RoleEditEventArgs(RoleNameTextBox.Text));
        }
Exemple #2
0
        public void CreateRole()
        {
            CreatedRoleTextBox.Text = "";
            var db   = new Data.SecurityEntities();
            var role = new Data.Role()
            {
                ApplicationId   = new Guid(ApplicationIdTextBox.Text),
                Description     = DescriptionTextBox.Text,
                LoweredRoleName = RoleNameTextBox.Text.ToLower(),
                RoleId          = new Guid(RoleIdTextBox.Text),
                RoleName        = RoleNameTextBox.Text,
            };

            db.Roles.AddObject(role);
            db.SaveChanges();
            switch (PostCreateMode)
            {
            case PostCreateModeEnum.None:
                break;

            case PostCreateModeEnum.Create:
                PrepareToCreate();
                break;

            case PostCreateModeEnum.Update:
                PrepareToUpdate();
                LoadRole(role.RoleId);
                break;

            default:
                break;
            }
            CreateStatusLabel.ForeColor = System.Drawing.Color.Green;
            CreateStatusLabel.Text      = "Role '" + role.RoleName + "' was created.";
            CreatedRoleTextBox.Text     = role.RoleName;
            RiseCreated(new RoleEditEventArgs(role));
        }