Example #1
0
        public void SeedDb(PetShopContext context)
        {
            context.Database.EnsureCreated();

            string password = "******";

            byte[] passwordHashJoe, passwordSaltJoe, passwordHashAnn, passwordSaltAnn;
            authenticationHelper.CreatePasswordHash(password, out passwordHashJoe, out passwordSaltJoe);
            authenticationHelper.CreatePasswordHash(password, out passwordHashAnn, out passwordSaltAnn);

            var user = context.Users.Add(new User()
            {
                UserName     = "******",
                PasswordHash = passwordHashJoe,
                PasswordSalt = passwordSaltJoe,
                IsAdmin      = false
            });

            var user1 = context.Users.Add(new User()
            {
                UserName     = "******",
                PasswordHash = passwordHashAnn,
                PasswordSalt = passwordSaltAnn,
                IsAdmin      = true
            });

            var owner1 = context.Owners.Add(new Owner()
            {
                FirstName   = "Lady",
                LastName    = "Rainicorn",
                Address     = "Adventure road 104",
                Email       = "*****@*****.**",
                PhoneNumber = "45634523"
            }).Entity;

            var owner2 = context.Owners.Add(new Owner()
            {
                FirstName   = "Jake",
                LastName    = "Adventure",
                Address     = "Treehouse road 1",
                Email       = "*****@*****.**",
                PhoneNumber = "44578564"
            }).Entity;

            var pet1 = context.Pets.Add(new Pet()
            {
                Name          = "Finn",
                PetType       = "Human",
                PreviousOwner = owner2,
                BirthDate     = new DateTime(2000, 5, 23),
                SoldDate      = new DateTime(2002, 9, 2),
                Price         = 100
            }).Entity;

            var pet2 = context.Pets.Add(new Pet()
            {
                Name          = "Princess Bubblegum",
                PetType       = "cow",
                PreviousOwner = owner2,
                BirthDate     = new DateTime(2000, 5, 23),
                SoldDate      = new DateTime(2002, 9, 2),
                Price         = 10000
            }).Entity;

            context.SaveChanges();
        }
Example #2
0
        public static void Seed(PetShopContext dbFillContext)

        {
            Pet pet1 = new Pet
            {
                Birthdate    = DateTime.Now,
                Name         = " Trex ",
                Color        = " White ",
                Price        = 10000,
                Race         = "Dog",
                SoldDate     = DateTime.Now,
                PreviosOwner = " Bente "
            };

            Pet pet2 = new Pet
            {
                Birthdate    = DateTime.Now,
                Name         = " Rex ",
                Color        = " black ",
                Price        = 5000,
                Race         = "Cat",
                SoldDate     = DateTime.Now,
                PreviosOwner = " Bodil "
            };
            Pet pet3 = new Pet
            {
                Birthdate    = DateTime.Now,
                Name         = " Ricko ",
                Color        = " black ",
                Price        = 3000,
                Race         = "Dog",
                SoldDate     = DateTime.Now,
                PreviosOwner = " Klaus "
            };
            Pet pet4 = new Pet
            {
                Birthdate    = DateTime.Now,
                Name         = " Teison ",
                Color        = " white ",
                Price        = 7500,
                Race         = " Dog ",
                SoldDate     = DateTime.Now,
                PreviosOwner = " Camille "
            };
            Pet pet5 = new Pet
            {
                Birthdate    = DateTime.Now,
                Name         = " Coli ",
                Color        = " White ",
                Price        = 2000,
                Race         = "Goat",
                SoldDate     = DateTime.Now,
                PreviosOwner = " Bo "
            };
            Pet pet6 = new Pet
            {
                Birthdate    = DateTime.Now,
                Name         = " Dummi ",
                Color        = " orange ",
                Price        = 1000,
                Race         = " Cat ",
                SoldDate     = DateTime.Now,
                PreviosOwner = " Katrin "
            };

            dbFillContext.Add(pet1);
            dbFillContext.Add(pet2);
            dbFillContext.Add(pet3);
            dbFillContext.Add(pet4);
            dbFillContext.Add(pet5);
            dbFillContext.Add(pet6);


            Owner owner1 = new Owner
            {
                Name = " Karl "
            };

            Owner owner2 = new Owner
            {
                Name = " Carg "
            };

            Owner owner3 = new Owner
            {
                Name = " Farmand "
            };

            dbFillContext.Add(owner1);
            dbFillContext.Add(owner2);
            dbFillContext.Add(owner3);
            dbFillContext.SaveChanges();
        }
        public static void Initialize(PetShopContext ctx)
        {
            Pet pet1 = new Pet
            {
                name          = "Felix",
                type          = PetTypes.Cat,
                birthDate     = DateTime.Now,
                soldDate      = DateTime.Now.AddYears(1),
                color         = "Black",
                price         = 275,
                ownersHistory = new List <PetOwner>()
            };
            Pet pet2 = new Pet
            {
                name          = "Steggersaurus",
                type          = PetTypes.Dinosaurus,
                birthDate     = DateTime.Now.AddYears(-35),
                soldDate      = DateTime.Now.AddYears(1).AddDays(24),
                color         = "SteggerColor",
                price         = 550,
                ownersHistory = new List <PetOwner>()
            };
            Pet pet3 = new Pet
            {
                name          = "Snoopy",
                type          = PetTypes.Dog,
                birthDate     = DateTime.Now.AddYears(-35),
                soldDate      = DateTime.Now.AddYears(1).AddDays(24),
                color         = "White",
                price         = 550,
                ownersHistory = new List <PetOwner>()
            };
            Owner owner1 = new Owner
            {
                firstName  = "Post",
                lastName   = "Malone",
                address    = "Melonvej 24",
                petHistory = new List <PetOwner>()
            };
            Owner owner2 = new Owner
            {
                firstName  = "Daft",
                lastName   = "Punk",
                address    = "Elektronik Musikvej 1337",
                petHistory = new List <PetOwner>()
            };
            Owner owner3 = new Owner
            {
                firstName  = "Chris",
                lastName   = "McDonnel",
                address    = "Tomatvej 40",
                petHistory = new List <PetOwner>()
            };



            owner1 = ctx.Owners.Add(owner1).Entity;
            owner2 = ctx.Owners.Add(owner2).Entity;
            owner3 = ctx.Owners.Add(owner3).Entity;

            PetOwner PetOwner1 = new PetOwner
            {
                Owner = owner1
            };

            PetOwner PetOwner2 = new PetOwner
            {
                Owner = owner2
            };

            PetOwner PetOwner3 = new PetOwner
            {
                Owner = owner1
            };

            PetOwner PetOwner4 = new PetOwner
            {
                Owner = owner3
            };

            pet1.ownersHistory.Add(PetOwner1);
            pet1.ownersHistory.Add(PetOwner2);
            pet2.ownersHistory.Add(PetOwner3);
            pet3.ownersHistory.Add(PetOwner4);

            pet1 = ctx.Pets.Add(pet1).Entity;
            pet2 = ctx.Pets.Add(pet2).Entity;
            pet3 = ctx.Pets.Add(pet3).Entity;



            ctx.SaveChanges();
        }
 public PetSQLRepository(PetShopContext context)
 {
     _context = context;
 }