当前位置: 首页>>代码示例>>C#>>正文


C# Claim.Save方法代码示例

本文整理汇总了C#中Claim.Save方法的典型用法代码示例。如果您正苦于以下问题:C# Claim.Save方法的具体用法?C# Claim.Save怎么用?C# Claim.Save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Claim的用法示例。


在下文中一共展示了Claim.Save方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Seed

        /// <summary>
        /// Seeds the needed claims, usergroups and some users.
        /// </summary>
        public override void Seed()
        {
            var usergroupClaim = new Claim
            {
                Name = "Usergroups",
                Id = Guid.NewGuid(),
                Description = "Allows for viewing and editing of Usergroups."
            };

            usergroupClaim.Save();

            var userClaim = new Claim
            {
                Name = "Users",
                Id = Guid.NewGuid(),
                Description = "Allows for viewing and editing the Users."
            };

            userClaim.Save();

            var adminSectionClaim = new Claim
            {
                Name = "AdminOverview",
                Id = Guid.NewGuid(),
                Description = "Grants access to to the Administration section of the application."
            };

            adminSectionClaim.Save();

            var logClaim = new Claim
            {
                Name = "Log",
                Id = Guid.NewGuid(),
                Description = "Allows for viewing the Log."
            };

            logClaim.Save();

            var adminUsergroup = new Usergroup()
            {
                Name = "Administrator",
                Id = Guid.NewGuid()
            };

            adminUsergroup.Claims.Add(adminSectionClaim.Id);
            adminUsergroup.Claims.Add(usergroupClaim.Id);
            adminUsergroup.Claims.Add(userClaim.Id);
            adminUsergroup.Claims.Add(logClaim.Id);
            adminUsergroup.Save();

            var userUsergroup = new Usergroup()
            {
                Name = "User",
                Id = Guid.NewGuid()
            };

            userUsergroup.Save();

            var adminUser = new User
            {
                DateRegistered = DateTime.Now,
                Email = "[email protected]",
                Password = "pass",
                Id = Guid.NewGuid(),
                UserName = "admin",
                UsergroupId = adminUsergroup.Id
            };

            adminUser.EncodePassword();

            adminUser.Save();

            #if DEBUG
            var normalUser = new User
            {
                DateRegistered = DateTime.Now,
                Email = "[email protected]",
                Password = "user",
                Id = Guid.NewGuid(),
                UserName = "user",
                UsergroupId = userUsergroup.Id
            };

            normalUser.EncodePassword();
            normalUser.Save();
            #endif
        }
开发者ID:ajvorobiev,项目名称:DotNancyTemplate,代码行数:90,代码来源:20151011182650_1_+0_+0_CreateUsersTable.cs


注:本文中的Claim.Save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。