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();
        }
        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();
        }
Exemple #3
0
 public UserRepository(PetAppContext context)
 {
     _context = context;
 }
Exemple #4
0
 public PetRepository(PetAppContext context)
 {
     _context = context;
 }
Exemple #5
0
 public OwnerRepository(PetAppContext ctx)
 {
     _ctx = ctx;
 }
Exemple #6
0
 public OwnerRepository(PetAppContext pac)
 {
     _pac = pac;
 }
 public UserRepository(PetAppContext PActx)
 {
     _PActx = PActx;
 }
 public SQLAnimalRepository(PetAppContext context)
 {
     _context = context;
 }
Exemple #9
0
 public OwnerRepository(PetAppContext ptx)
 {
     _ptx = ptx;
 }
 public PetRepository(PetAppContext ptx)
 {
     _ptx = ptx;
 }
 public PetRepository(PetAppContext ctx)
 {
     _ctx = ctx;
 }
Exemple #12
0
 public SQLShelterRepository(PetAppContext context)
 {
     _context = context;
 }
 public TodoItemRepository(PetAppContext context)
 {
     db = context;
 }
Exemple #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();
        }
 public PetsController(PetAppContext context)
 {
     _context = context;
 }
Exemple #16
0
 public PetRepository(PetAppContext pac)
 {
     _pac = pac;
 }