Created
January 13, 2019 11:31
-
-
Save ivanvs/555142dfc2179231c2fb050627c97aa8 to your computer and use it in GitHub Desktop.
Ispravke kako bi sistem radio
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class AuthContext : IdentityDbContext<ApplicationUser> | |
| { | |
| public AuthContext() : base("AuthContext") | |
| { | |
| Database.SetInitializer(new InitializeWithDefaultData()); | |
| } | |
| protected override void OnModelCreating(DbModelBuilder modelBuilder) | |
| { | |
| base.OnModelCreating(modelBuilder); | |
| modelBuilder.Entity<Student>().ToTable("Student"); | |
| modelBuilder.Entity<AdminUser>().ToTable("AdminUser"); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class InitializeWithDefaultData : DropCreateDatabaseAlways<AuthContext> | |
| { | |
| protected override void Seed(AuthContext context) | |
| { | |
| var store = new RoleStore<IdentityRole>(context); | |
| var manager = new RoleManager<IdentityRole>(store); | |
| manager.Create(new IdentityRole("admins")); | |
| manager.Create(new IdentityRole("userStudent")); | |
| var userStore = new UserStore<ApplicationUser>(context); | |
| var userManager = new UserManager<ApplicationUser>(userStore); | |
| Student student = new Student(); | |
| student.UserName = "[email protected]"; | |
| student.FirstName = "Ivan"; | |
| student.LastName = "Vasiljevic"; | |
| student.JMBG = "0000000000000"; | |
| userManager.Create(student, "testna_sifra"); | |
| userManager.AddToRole(student.Id, "userStudent"); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment