Пример #1
0
 public PetRepository(PetAppContext pac)
 {
     _pac = pac;
 }
Пример #2
0
        public static void SeedDB(PetAppContext ctx)
        {
            //ctx.Database.EnsureDeleted();
            ctx.Database.EnsureCreated();


            List <TodoItem> items = new List <TodoItem>
            {
                new TodoItem {
                    IsComplete = true, Name = "Make homework"
                },
                new TodoItem {
                    IsComplete = false, Name = "Sleep"
                }
            };
            // Create two users with hashed and salted passwords
            string password = "******";

            byte[] passwordHashSusi, passwordSaltSusi, passwordHashSam, passwordSaltSam;
            CreatePasswordHash(password, out passwordHashSusi, out passwordSaltSusi);
            CreatePasswordHash(password, out passwordHashSam, out passwordSaltSam);


            var owner1 = ctx.Owners.Add(new Owner()
            {
                FirstName   = "Susana",
                LastName    = "Caparros",
                Address     = "MyHeart<3",
                PhoneNumber = 060606060,
                Email       = "*****@*****.**",
            }).Entity;
            var owner2 = ctx.Owners.Add(new Owner()
            {
                FirstName   = "Samuel",
                LastName    = "Caparros",
                Address     = "Doom",
                PhoneNumber = 123456789,
                Email       = "*****@*****.**",
            }).Entity;

            var pet1 = ctx.Pets.Add(new Pet()
            {
                Birthday = new DateTime(1997, 3, 18),
                Owner    = owner1,
                SoldDate = new DateTime(2016, 8, 26),
                Color    = "White",
                Race     = "Programmer",
                Type     = "Student",
                Price    = -4450
            }).Entity;

            var customer1 = ctx.Customers.Add(new Customer()
            {
                // ID = 1,
                FirstName    = "SamuelLDB",
                LastName     = "CaparrosLDB",
                Address      = "1234LDB",
                PasswordHash = passwordHashSam,
                PasswordSalt = passwordSaltSam,
                IsAdmin      = true
            }).Entity;
            var customer2 = ctx.Customers.Add(new Customer()
            {
                // ID = 1,
                FirstName    = "Susana",
                LastName     = "Caparros",
                Address      = "Malaga",
                PasswordHash = passwordHashSusi,
                PasswordSalt = passwordSaltSusi,
                IsAdmin      = true
            }).Entity;

            ctx.Customers.AddRange(customer1);
            ctx.SaveChanges();
        }
Пример #3
0
 public OwnerRepository(PetAppContext pac)
 {
     _pac = pac;
 }
Пример #4
0
 public CustomerRepository(PetAppContext pac)
 {
     _pac = pac;
 }