當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。