本文整理汇总了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
}