summaryrefslogtreecommitdiff
path: root/Project-Unite
diff options
context:
space:
mode:
authorMichael <[email protected]>2017-03-21 11:26:06 -0400
committerMichael <[email protected]>2017-03-21 11:26:06 -0400
commita6e9911eab809519461dca5b4c12783f52d5190e (patch)
tree1f8861dd730149cd3d1a3dc0e02e85115fe97cbf /Project-Unite
parentd2cf4c4d45ea7d96172130b5ae84487e977f5224 (diff)
downloadproject-unite-a6e9911eab809519461dca5b4c12783f52d5190e.tar.gz
project-unite-a6e9911eab809519461dca5b4c12783f52d5190e.tar.bz2
project-unite-a6e9911eab809519461dca5b4c12783f52d5190e.zip
We now seed some fundamental roles on db create
Diffstat (limited to 'Project-Unite')
-rw-r--r--Project-Unite/Migrations/Configuration.cs41
1 files changed, 29 insertions, 12 deletions
diff --git a/Project-Unite/Migrations/Configuration.cs b/Project-Unite/Migrations/Configuration.cs
index a53d73e..3f3fa57 100644
--- a/Project-Unite/Migrations/Configuration.cs
+++ b/Project-Unite/Migrations/Configuration.cs
@@ -9,24 +9,41 @@ namespace Project_Unite.Migrations
{
public Configuration()
{
- AutomaticMigrationsEnabled = false;
+ AutomaticMigrationsEnabled = true;
ContextKey = "Project_Unite.Models.ApplicationDbContext";
}
protected override void Seed(Project_Unite.Models.ApplicationDbContext context)
{
- // This method will be called after migrating to the latest version.
- // You can use the DbSet<T>.AddOrUpdate() helper extension method
- // to avoid creating duplicate seed data. E.g.
- //
- // context.People.AddOrUpdate(
- // p => p.FullName,
- // new Person { FullName = "Andrew Peters" },
- // new Person { FullName = "Brice Lambson" },
- // new Person { FullName = "Rowan Miller" }
- // );
- //
+ var adm = new Models.Role
+ {
+ Id = "administrator",
+ ColorHex = "#FF0000",
+ Description = "These are the admins of the website - This is a persistent group and cannot be deleted.",
+ Priority = context.Roles.Count() + 1,
+ Name = "Administrators"
+ });
+ foreach (var prop in adm.GetType().GetProperties(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance))
+ {
+ if (prop.Name.StartsWith("Can") && prop.PropertyType == typeof(bool))
+ {
+ prop.SetValue(adm, true);
+ }
+ }
+ context.Roles.AddOrUpdate(adm);
+ var userRole = new Models.Role
+ {
+ Name = "Users",
+ Id = "user",
+ Description = "This is the default role for all new users. This role's priority may not be modified, and this role may not be deleted.",
+ Priority = 0,
+ ColorHex = "#FFF"
+ };
+ context.Roles.AddOrUpdate(userRole);
+
+
}
+
}
}