Skip to content

Instantly share code, notes, and snippets.

@ivanvs
Created January 13, 2019 11:31
Show Gist options
  • Select an option

  • Save ivanvs/555142dfc2179231c2fb050627c97aa8 to your computer and use it in GitHub Desktop.

Select an option

Save ivanvs/555142dfc2179231c2fb050627c97aa8 to your computer and use it in GitHub Desktop.
Ispravke kako bi sistem radio
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");
}
}
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