-
Notifications
You must be signed in to change notification settings - Fork 3
/
Startup.cs
40 lines (35 loc) · 1.15 KB
/
Startup.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using Library.Models;
using Microsoft.AspNet.Identity;
using Microsoft.Owin;
using Owin;
using Microsoft.AspNet.Identity.EntityFramework;
[assembly: OwinStartupAttribute(typeof(Library.Startup))]
namespace Library
{
public partial class Startup
{
ApplicationDbContext db = new ApplicationDbContext();
public void Configuration(IAppBuilder app)
{
ConfigureAuth(app);
CreateRoles();
//CreateUsers();
}
//public void CreateUsers()
//{
// var userManager = new UserManager<ApplicationUser, int>(new UserStore<ApplicationUser, CustomRole, int, CustomUserLogin, CustomUserRole, CustomUserClaim>(db));
// var user = new ApplicationUser();
// userManager.AddToRole(7, "Admins");
//}
public void CreateRoles()
{
var roleManager = new RoleManager<CustomRole,int>(new CustomRoleStore(db));
if (!roleManager.RoleExists("Admins"))
{
CustomRole role = new CustomRole();
role.Name = "Admins";
roleManager.Create(role);
}
}
}
}