本文整理匯總了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
}