예제 #1
0
        public static void SeedDB(PetAppContext ctx)
        {
            ctx.Database.EnsureDeleted();
            ctx.Database.EnsureCreated();

            var owner1 = ctx.Owners.Add(new Owner()
            {
                Name = "John Hitler"
            }).Entity;

            var owner2 = ctx.Owners.Add(new Owner()
            {
                Name = "Rigtig Brian"
            }).Entity;

            var pet1 = ctx.Pets.Add(new Pet()
            {
                BirthDate      = DateTime.Now,
                Price          = 1,
                SoldDate       = DateTime.MinValue,
                Name           = "DinMor",
                Color          = "Black",
                Type           = "Human",
                PreviousOwners = new List <PetOwner>
                {
                    new PetOwner()
                    {
                        Owner = owner1
                    },
                    new PetOwner()
                    {
                        Owner = owner2
                    }
                }
            }).Entity;
            string password = "******";

            byte[] passwordHashUserOne, passwordSaltUserOne, passwordHashUserTwo, passwordSaltUserTwo;

            CreatePasswordHash(password, out passwordHashUserOne, out passwordSaltUserOne);
            CreatePasswordHash(password, out passwordHashUserTwo, out passwordSaltUserTwo);

            var userNormal = ctx.Users.Add(new User()
            {
                IsAdmin      = false,
                Username     = "******",
                PasswordSalt = passwordSaltUserOne,
                PasswordHash = passwordHashUserOne
            }).Entity;

            var userAdmin = ctx.Users.Add(new User()
            {
                IsAdmin      = true,
                Username     = "******",
                PasswordSalt = passwordSaltUserTwo,
                PasswordHash = passwordHashUserTwo
            }).Entity;

            ctx.SaveChanges();
        }
예제 #2
0
        public static void SeedDB(PetAppContext ctx)
        {
            ctx.Database.EnsureDeleted();
            ctx.Database.EnsureCreated();
            var pat1 = ctx.Pets.Add(new Pet()
            {
                Name          = "Malti",
                Species       = "Naga",
                Color         = "Blue",
                Birthdate     = DateTime.Parse("05-01-2009 "),
                SoldDate      = DateTime.Parse("23-03-2015 "),
                PreviousOwner = "Blilly Jack",
                Price         = 4999.99,
            });

            ctx.SaveChanges();
        }
예제 #3
0
 public UserRepository(PetAppContext context)
 {
     _context = context;
 }
예제 #4
0
 public PetRepository(PetAppContext context)
 {
     _context = context;
 }
예제 #5
0
 public OwnerRepository(PetAppContext ctx)
 {
     _ctx = ctx;
 }
예제 #6
0
 public OwnerRepository(PetAppContext pac)
 {
     _pac = pac;
 }
예제 #7
0
 public UserRepository(PetAppContext PActx)
 {
     _PActx = PActx;
 }
예제 #8
0
 public SQLAnimalRepository(PetAppContext context)
 {
     _context = context;
 }
예제 #9
0
 public OwnerRepository(PetAppContext ptx)
 {
     _ptx = ptx;
 }
예제 #10
0
 public PetRepository(PetAppContext ptx)
 {
     _ptx = ptx;
 }
 public PetRepository(PetAppContext ctx)
 {
     _ctx = ctx;
 }
예제 #12
0
 public SQLShelterRepository(PetAppContext context)
 {
     _context = context;
 }
예제 #13
0
 public TodoItemRepository(PetAppContext context)
 {
     db = context;
 }
예제 #14
0
        public static void SeedDB(PetAppContext ctx)
        {
            //ctx.Database.EnsureDeleted();
            ctx.Database.EnsureCreated();

            var owner1 = ctx.Owners.Add(new Owner()
            {
                Name = "OwnerPerson1"
            }).Entity;

            var owner2 = ctx.Owners.Add(new Owner()
            {
                Name = "OwnerPerson2"
            }).Entity;

            var pet1 = ctx.Pets.Add(new Pet()
            {
                BirthDate      = DateTime.Now,
                Price          = 1,
                SoldDate       = DateTime.MinValue,
                Name           = "Dyr",
                Color          = "Black",
                Type           = "Dog",
                PreviousOwners = new List <PetOwner>
                {
                    new PetOwner()
                    {
                        Owner = owner1
                    },
                    new PetOwner()
                    {
                        Owner = owner2
                    }
                }
            }).Entity;

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

            byte[] passwordHashUserOne, passwordSaltUserOne, passwordHashUserTwo, passwordSaltUserTwo;

            CreatePasswordHash(password, out passwordHashUserOne, out passwordSaltUserOne);
            CreatePasswordHash(password, out passwordHashUserTwo, out passwordSaltUserTwo);


            var user1 = ctx.Users.Add(new User()
            {
                Username     = "******",
                PasswordHash = passwordHashUserOne,
                PasswordSalt = passwordSaltUserOne,
                IsAdmin      = false,
                Owner        = owner1,
                OwnerRef     = owner1.Id
            }).Entity;

            var user2 = ctx.Users.Add(new User()
            {
                Username     = "******",
                PasswordHash = passwordHashUserTwo,
                PasswordSalt = passwordSaltUserTwo,
                IsAdmin      = true,
                Owner        = owner2,
                OwnerRef     = owner2.Id
            }).Entity;

            ctx.SaveChanges();
        }
예제 #15
0
 public PetsController(PetAppContext context)
 {
     _context = context;
 }
예제 #16
0
 public PetRepository(PetAppContext pac)
 {
     _pac = pac;
 }