Beispiel #1
0
        public MyEstateTestBase()
        {
            var options = new DbContextOptionsBuilder <MyEstateContext>()
                          .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString())
                          .Options;

            _context = new MyEstateContext(options);

            _context.Database.EnsureCreated();

            MyEstateInitializer.Initialize(_context);
        }
Beispiel #2
0
 public AuthRepository(MyEstateContext context)
 {
     _context = context;
 }
Beispiel #3
0
 public AdminController(MyEstateContext context, UserManager <User> userManager)
 {
     _context     = context;
     _userManager = userManager;
 }
Beispiel #4
0
 public EstateAgentsRepository(MyEstateContext context)
 {
     _context = context;
 }
Beispiel #5
0
 public DatingRepository(MyEstateContext context)
 {
     _context = context;
 }
Beispiel #6
0
            internal static void Initialize(MyEstateContext context)
            {
                var users = new[]
                {
                    new Domain.Entities.User {
                        UserName = "******"
                    },
                    new Domain.Entities.User {
                        UserName = "******"
                    },
                    new Domain.Entities.User {
                        UserName = "******"
                    },
                    new Domain.Entities.User {
                        UserName = "******"
                    }
                };

                var estates = new[]
                {
                    new Domain.Entities.Estate()
                    {
                        AdType      = "Selling",
                        Title       = "TestTitle1",
                        Description = "Description1",
                        Price       = 100000,
                        Square      = 50,
                        Rooms       = 3,
                        Floors      = 2,
                        Country     = "Greece",
                        City        = "Afina",
                        Street      = "Firts"
                    },
                    new Domain.Entities.Estate()
                    {
                        AdType      = "Rent",
                        Title       = "TestTitle2",
                        Description = "Description2",
                        Price       = 3000,
                        Square      = 60,
                        Rooms       = 4,
                        Floors      = 1,
                        Country     = "Poland",
                        City        = "Wroclaw",
                        Street      = "Second"
                    },
                    new Domain.Entities.Estate()
                    {
                        AdType      = "Daily rent",
                        Title       = "TestTitle3",
                        Description = "Description3",
                        Price       = 600,
                        Square      = 40,
                        Rooms       = 2,
                        Floors      = 1,
                        Country     = "Ukraine",
                        City        = "Lviv",
                        Street      = "Shevchenka"
                    }
                };

                var estateAgents = new[]
                {
                    new Domain.Entities.EstateAgent()
                    {
                        Name   = "John",
                        Gender = "Male",
                        Age    = 25,
                        City   = "Lviv"
                    },
                    new Domain.Entities.EstateAgent()
                    {
                        Name   = "Julia",
                        Gender = "Female ",
                        Age    = 24,
                        City   = "Kiev"
                    },
                    new Domain.Entities.EstateAgent()
                    {
                        Name   = "Steve",
                        Gender = "Male",
                        Age    = 34,
                        City   = "Odesa"
                    }
                };

                context.Users.AddRange(users);
                context.Estates.AddRange(estates);
                context.EstateAgents.AddRange(estateAgents);

                context.SaveChanges();
            }