/// <summary>
        /// seeder method override, to seed inital users, roles and objects
        /// </summary>
        protected override void Seed(ApplicationDbContext context)
        {
            base.Seed(context);

            //creates staff roles

            if (!context.Users.Any())
            {
                RoleManager <IdentityRole> roleManager = new RoleManager <IdentityRole>(new RoleStore <IdentityRole>(context));

                if (!roleManager.RoleExists("StaffAdmin"))
                {
                    roleManager.Create(new IdentityRole("StaffAdmin"));
                }

                if (!roleManager.RoleExists("MedicalRecordsStaff"))
                {
                    roleManager.Create(new IdentityRole("MedicalRecordsStaff"));
                }

                if (!roleManager.RoleExists("Nurse"))
                {
                    roleManager.Create(new IdentityRole("Nurse"));
                }

                if (!roleManager.RoleExists("StaffNurse"))
                {
                    roleManager.Create(new IdentityRole("StaffNurse"));
                }

                if (!roleManager.RoleExists("WardSister"))
                {
                    roleManager.Create(new IdentityRole("WardSister"));
                }

                if (!roleManager.RoleExists("Doctor"))
                {
                    roleManager.Create(new IdentityRole("Doctor"));
                }

                if (!roleManager.RoleExists("Consultant"))
                {
                    roleManager.Create(new IdentityRole("Consultant"));
                }

                context.SaveChanges();
            }

            //creates staff users

            UserManager <ApplicationUser> userManager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(context));

            if (userManager.FindByName("*****@*****.**") == null)
            {
                var staffAdmin = new StaffAdmin
                {
                    UserName       = "******",
                    Email          = "*****@*****.**",
                    EmailConfirmed = true,
                    Forename       = "Sam",
                    Surname        = "Simpson",
                    DOB            = DateTime.Now,
                    Street         = "Street",
                    City           = "City",
                    Town           = "Town",
                    PhoneNumber    = "0005550000"
                };
                userManager.Create(staffAdmin, "password123");
                userManager.AddToRole(staffAdmin.Id, "StaffAdmin");
            }

            if (userManager.FindByName("*****@*****.**") == null)
            {
                var medicalRecordsStaff = new MedicalRecordsStaff
                {
                    UserName       = "******",
                    Email          = "*****@*****.**",
                    EmailConfirmed = true,
                    Forename       = "Fred",
                    Surname        = "Carlson",
                    DOB            = DateTime.Now,
                    Street         = "Street",
                    City           = "City",
                    Town           = "Town",
                    PhoneNumber    = "0005550000"
                };
                userManager.Create(medicalRecordsStaff, "password123");
                userManager.AddToRole(medicalRecordsStaff.Id, "MedicalRecordsStaff");
            }

            if (userManager.FindByName("*****@*****.**") == null)
            {
                var wardSister = new WardSister
                {
                    UserName       = "******",
                    Email          = "*****@*****.**",
                    EmailConfirmed = true,
                    Forename       = "Lilith",
                    Surname        = "Fray",
                    DOB            = DateTime.Now,
                    Street         = "Street",
                    City           = "City",
                    Town           = "Town",
                    PhoneNumber    = "0005550000"
                };
                userManager.Create(wardSister, "password123");
                userManager.AddToRole(wardSister.Id, "WardSister");
            }

            if (userManager.FindByName("*****@*****.**") == null)
            {
                var Nurse = new Nurse
                {
                    UserName       = "******",
                    Email          = "*****@*****.**",
                    EmailConfirmed = true,
                    Forename       = "Liam",
                    Surname        = "Daniels",
                    DOB            = DateTime.Now,
                    Street         = "Street",
                    City           = "City",
                    Town           = "Town",
                    PhoneNumber    = "0005550000"
                };
                userManager.Create(Nurse, "password123");
                userManager.AddToRole(Nurse.Id, "Nurse");
            }

            if (userManager.FindByName("*****@*****.**") == null)
            {
                var StaffNurse = new StaffNurse
                {
                    UserName       = "******",
                    Email          = "*****@*****.**",
                    EmailConfirmed = true,
                    Forename       = "Tay",
                    Surname        = "Lewis",
                    DOB            = DateTime.Now,
                    Street         = "Street",
                    City           = "City",
                    Town           = "Town",
                    PhoneNumber    = "0005550000"
                };
                userManager.Create(StaffNurse, "password123");
                userManager.AddToRole(StaffNurse.Id, "StaffNurse");
            }

            if (userManager.FindByName("*****@*****.**") == null)
            {
                var JuniorDoctor = new Doctor
                {
                    UserName       = "******",
                    Email          = "*****@*****.**",
                    EmailConfirmed = true,
                    Forename       = "Vargas",
                    Surname        = "Taylor",
                    DOB            = DateTime.Now,
                    Street         = "Street",
                    City           = "City",
                    Town           = "Town",
                    PhoneNumber    = "0005550000",
                    Grade          = 'X',
                    Specialism     = "Dentistry"
                };
                userManager.Create(JuniorDoctor, "password123");
                userManager.AddToRole(JuniorDoctor.Id, "Doctor");
            }

            if (userManager.FindByName("*****@*****.**") == null)
            {
                var Doctor = new Doctor
                {
                    UserName       = "******",
                    Email          = "*****@*****.**",
                    EmailConfirmed = true,
                    Forename       = "Brie",
                    Surname        = "Tracer",
                    DOB            = DateTime.Now,
                    Street         = "Street",
                    City           = "City",
                    Town           = "Town",
                    PhoneNumber    = "0005550000",
                    Grade          = 'A',
                    Specialism     = "Gastrology"
                };
                userManager.Create(Doctor, "password123");
                userManager.AddToRole(Doctor.Id, "Doctor");
            }

            if (userManager.FindByName("*****@*****.**") == null)
            {
                var consultant = new Consultant
                {
                    UserName       = "******",
                    Email          = "*****@*****.**",
                    EmailConfirmed = true,
                    Forename       = "Fred",
                    Surname        = "Carlson",
                    DOB            = DateTime.Now,
                    Street         = "Street",
                    City           = "City",
                    Town           = "Town",
                    PhoneNumber    = "0005550000",
                    Specialism     = "Phiso",
                    Grade          = 'A'
                };
                userManager.Create(consultant, "password123");
                userManager.AddToRole(consultant.Id, "Consultant");
            }

            context.SaveChanges();

            //object seeds

            //wards

            if (!context.Wards.Any())
            {
                context.Wards.Add(new Ward {
                    WardName = "Dentistry", WardCapacity = 27
                });
                context.Wards.Add(new Ward {
                    WardName = "Orthadontics", WardCapacity = 27
                });
                context.Wards.Add(new Ward {
                    WardName = "Phisio", WardCapacity = 27
                });
                context.Wards.Add(new Ward {
                    WardName = "dermatology", WardCapacity = 27
                });

                context.SaveChanges();
            }

            //teams

            if (!context.Teams.Any())
            {
                context.Teams.Add(new Team {
                    TeamName = "Dentistry"
                });
                context.Teams.Add(new Team {
                    TeamName = "Orthadontics"
                });

                context.SaveChanges();
            }

            //drugs

            if (!context.Drugs.Any())
            {
                context.Drugs.Add(new Drug {
                    DrugName = "Anastetic", DrugDetails = "sleep medicine", DrugCost = 0.35
                });
                context.Drugs.Add(new Drug {
                    DrugName = "Nostro", DrugDetails = "Nose medicine", DrugCost = 0.49
                });
                context.Drugs.Add(new Drug {
                    DrugName = "Generic Technologies HeartMed", DrugDetails = "Reboot the heart in 1 min", DrugCost = 0.35
                });
                context.Drugs.Add(new Drug {
                    DrugName = "GastroBegone", DrugDetails = "EXPLOSIVE results, warning rear passage not guranteed for reattachment", DrugCost = 0.49
                });

                context.SaveChanges();
            }

            //patients

            if (!context.Patients.Any())
            {
                context.Patients.Add(new Patient {
                    Email = "*****@*****.**", Forename = "Dan", Surname = "Russ", Street = "dolph", Town = "towni", City = "county", DOB = DateTime.Now, Occupation = "Unemployed", TelNum = "07903899757"
                });
                context.Patients.Add(new Patient {
                    Email = "*****@*****.**", Forename = "Jill", Surname = "willis", Street = "dolph", Town = "towni", City = "county", DOB = DateTime.Now, Occupation = "Unemployed", TelNum = "07903899757"
                });
                context.Patients.Add(new Patient {
                    Email = "*****@*****.**", Forename = "Dawn", Surname = "furgus", Street = "dolph", Town = "towni", City = "county", DOB = DateTime.Now, Occupation = "Unemployed", TelNum = "07903899757"
                });

                context.SaveChanges();
            }

            //admissions

            if (!context.Admissions.Any())
            {
                context.SaveChanges();
            }

            //treatment invoices

            if (!context.BillingInvoices.Any())
            {
                context.SaveChanges();
            }

            //payments

            if (!context.Payments.Any())
            {
                context.SaveChanges();
            }

            //prescriptions, not proscriptions :V

            if (!context.Prescriptions.Any())
            {
                context.SaveChanges();
            }

            //Treatments

            if (!context.Treatments.Any())
            {
                context.SaveChanges();
            }
        }
Ejemplo n.º 2
0
 public StaffAdmin(StaffAdmin staffAdmin)
 {
 }