Fix build issues in Startup.cs

Update for Identity API changes
This commit is contained in:
Hao Kung 2014-04-04 14:55:47 -07:00
parent e4af75dddf
commit 5bb8f602f1
1 changed files with 6 additions and 6 deletions

View File

@ -81,22 +81,22 @@ public class Startup
string _password = "YouShouldChangeThisPassword"; // configuration.Get("DefaultAdminPassword"); string _password = "YouShouldChangeThisPassword"; // configuration.Get("DefaultAdminPassword");
string _role = "Administrator"; string _role = "Administrator";
var userManager = new UserManager<ApplicationUser, string>(new InMemoryUserStore<ApplicationUser>()); var userManager = new UserManager<ApplicationUser>(new InMemoryUserStore<ApplicationUser>());
var roleManager = new RoleManager<InMemoryRole>(new InMemoryRoleStore<InMemoryRole>()); var roleManager = new RoleManager<InMemoryRole>(new InMemoryRoleStore<InMemoryRole>());
var role = new InMemoryRole(_role); var role = new InMemoryRole(_role);
var result = await roleManager.RoleExists(_role); var result = await roleManager.RoleExistsAsync(_role);
if (result == false) if (result == false)
{ {
await roleManager.Create(role); await roleManager.CreateAsync(role);
} }
var user = await userManager.FindByName(_username); var user = await userManager.FindByNameAsync(_username);
if (user == null) if (user == null)
{ {
user = new ApplicationUser { UserName = _username }; user = new ApplicationUser { UserName = _username };
await userManager.Create(user, _password); await userManager.CreateAsync(user, _password);
await userManager.AddToRole(user.Id, _role); await userManager.AddToRoleAsync(user.Id, _role);
} }
} }
} }