Ejemplo n.º 1
0
        public HomeHunterDbContext GetDbContext()
        {
            var optionsBuilder = new DbContextOptionsBuilder <HomeHunterDbContext>()
                                 .UseInMemoryDatabase(Guid.NewGuid().ToString());

            var context = new HomeHunterDbContext(optionsBuilder.Options);

            return(context);
        }
Ejemplo n.º 2
0
        public static HomeHunterDbContext GetDbContext()
        {
            var optionsBuilder = new DbContextOptionsBuilder <HomeHunterDbContext>()
                                 .UseInMemoryDatabase("TestDb");

            var context = new HomeHunterDbContext(optionsBuilder.Options);

            return(context);
        }
Ejemplo n.º 3
0
        public async Task SeedAsync(HomeHunterDbContext dbContext, IServiceProvider serviceProvider)
        {
            var roleManager = serviceProvider.GetRequiredService <RoleManager <IdentityRole> >();
            var usermanager = serviceProvider.GetRequiredService <UserManager <HomeHunterUser> >();

            await SeedRoleAsync(roleManager, GlobalConstants.AdministratorRoleName);
            await SeedRoleAsync(roleManager, GlobalConstants.UserRoleName);
            await SeedUserAdminRole(usermanager);
        }
Ejemplo n.º 4
0
 public StatisticServices(HomeHunterDbContext context,
                          IUserServices userServices,
                          IVisitorSessionServices visitorSessionServices
                          )
 {
     this.context                = context;
     this.userServices           = userServices;
     this.visitorSessionServices = visitorSessionServices;
 }
Ejemplo n.º 5
0
 public UserServices(HomeHunterDbContext context,
                     IMapper mapper,
                     UserManager <HomeHunterUser> userManager,
                     IApplicationEmailSender emailSender)
 {
     this.context     = context;
     this.mapper      = mapper;
     this.userManager = userManager;
     this.emailSender = emailSender;
 }
 public ImageServices(
     HomeHunterDbContext context,
     IMapper mapper,
     IRealEstateServices realEstateServices,
     IHostingEnvironment hostingEnvironment)
 {
     this.context            = context;
     this.mapper             = mapper;
     this.realEstateServices = realEstateServices;
     this.hostingEnvironment = hostingEnvironment;
 }
Ejemplo n.º 7
0
 public OfferServicesTests()
 {
     this.context                  = InMemoryDatabase.GetDbContext();
     this.mapper                   = this.GetMapper();
     this.imageServices            = new Mock <IImageServices>();
     this.cloudinaryServices       = new Mock <ICloudinaryService>();
     this.userServices             = new Mock <IUserServices>();
     this.realEstateServices       = new Mock <IRealEstateServices>();
     this.referenceNumberGenerator = new Mock <IReferenceNumberGenerator>();
     this.SeedData();
 }
 public RealEstateServicesTests()
 {
     this.context = InMemoryDatabase.GetDbContext();
     this.SeedData();
     this.realEstateTypeServices = new Mock <IRealEstateTypeServices>();
     this.citiesServices         = new Mock <ICitiesServices>();
     this.neighbourhoodServices  = new Mock <INeighbourhoodServices>();
     this.addressServices        = new Mock <IAddressServices>();
     this.villageServices        = new Mock <IVillageServices>();
     this.buildingTypeServices   = new Mock <IBuildingTypeServices>();
     this.heatingSystemServices  = new Mock <IHeatingSystemServices>();
 }
Ejemplo n.º 9
0
 public OfferServices(HomeHunterDbContext context,
                      IImageServices imageServices,
                      ICloudinaryService cloudinaryService,
                      IUserServices userServices,
                      IReferenceNumberGenerator referenceNumberGenerator,
                      IMapper mapper)
 {
     this.context                  = context;
     this.imageServices            = imageServices;
     this.cloudinaryService        = cloudinaryService;
     this.userServices             = userServices;
     this.referenceNumberGenerator = referenceNumberGenerator;
     this.mapper = mapper;
 }
Ejemplo n.º 10
0
 public RealEstateServices(HomeHunterDbContext context,
                           IRealEstateTypeServices realEstateTypeServices,
                           ICitiesServices citiesServices,
                           INeighbourhoodServices neighbourhoodServices,
                           IAddressServices addressServices,
                           IVillageServices villageServices,
                           IBuildingTypeServices buildingTypeServices,
                           IHeatingSystemServices heatingSystemServices,
                           IMapper mapper)
 {
     this.context = context;
     this.realEstateTypeServices = realEstateTypeServices;
     this.citiesServices         = citiesServices;
     this.neighbourhoodServices  = neighbourhoodServices;
     this.addressServices        = addressServices;
     this.villageServices        = villageServices;
     this.buildingTypeServices   = buildingTypeServices;
     this.heatingSystemServices  = heatingSystemServices;
     this.mapper = mapper;
 }
Ejemplo n.º 11
0
        private static async Task SeedCitiesAsync(string[] cities, HomeHunterDbContext dbContext)
        {
            var citiesFromDb = dbContext.Cities.ToList();

            var createdCities = new List <City>();

            foreach (var name in cities)
            {
                if (!citiesFromDb.Any(x => x.Name == name))
                {
                    createdCities.Add(new City
                    {
                        Name      = name,
                        CreatedOn = DateTime.UtcNow,
                    });
                }
            }
            await dbContext.Cities.AddRangeAsync(createdCities);

            await dbContext.SaveChangesAsync();
        }
Ejemplo n.º 12
0
        private static async Task SeedCitiesAsync(string[] buildingTypes, HomeHunterDbContext dbContext)
        {
            var buildingTypesFromDb = dbContext.BuildingTypes.ToList();

            var createdBuildigTypes = new List <BuildingType>();

            foreach (var type in buildingTypes)
            {
                if (!buildingTypesFromDb.Any(x => x.Name == type))
                {
                    createdBuildigTypes.Add(new BuildingType
                    {
                        Name      = type,
                        CreatedOn = DateTime.Now,
                    });
                }
            }

            await dbContext.BuildingTypes.AddRangeAsync(createdBuildigTypes);

            await dbContext.SaveChangesAsync();
        }
Ejemplo n.º 13
0
 public ImageServices(HomeHunterDbContext context, IMapper mapper, IRealEstateServices realEstateServices)
 {
     this.context            = context;
     this.mapper             = mapper;
     this.realEstateServices = realEstateServices;
 }
Ejemplo n.º 14
0
 public async Task SeedAsync(HomeHunterDbContext dbContext, IServiceProvider serviceProvider)
 {
     await SeedCitiesAsync(BuildingTypes, dbContext);
 }
 public HeatingSystemServices(HomeHunterDbContext context)
 {
     this.context = context;
 }
Ejemplo n.º 16
0
 public CitiesServices(HomeHunterDbContext context)
 {
     this.context = context;
 }
Ejemplo n.º 17
0
 public AddressServices(HomeHunterDbContext context)
 {
     this.context = context;
 }
 public VisitorsSessionServicesTests()
 {
     this.context = InMemoryDatabase.GetDbContext();
     this.SeedData();
 }
 public ReferenceNumberGenerator(HomeHunterDbContext context)
 {
     this.context = context;
 }
Ejemplo n.º 20
0
 public UsersServicesTests()
 {
     this.context = InMemoryDatabase.GetDbContext();
 }
Ejemplo n.º 21
0
 public async Task SeedAsync(HomeHunterDbContext dbContext, IServiceProvider serviceProvider)
 {
     await SeedNeighbourhoodsAsync(GlobalConstants.ImotBgSofiaDistricts, dbContext);
 }
Ejemplo n.º 22
0
        private static async Task SeedHeatingSystemsAsync(string[] heatingSystemsList, HomeHunterDbContext dbContext)
        {
            var heatingSystemTypesFromDb = dbContext.HeatingSystems.ToList();
            var createdTypes             = new List <HeatingSystem>();

            foreach (var type in heatingSystemsList)
            {
                if (!heatingSystemTypesFromDb.Any(x => x.Name == type))
                {
                    createdTypes.Add(new HeatingSystem {
                        Name = type, CreatedOn = DateTime.UtcNow
                    });
                }
            }

            await dbContext.HeatingSystems.AddRangeAsync(createdTypes);

            await dbContext.SaveChangesAsync();
        }
Ejemplo n.º 23
0
 public async Task SeedAsync(HomeHunterDbContext dbContext, IServiceProvider serviceProvider)
 {
     await SeedHeatingSystemsAsync(HeatingSystemsList, dbContext);
 }
Ejemplo n.º 24
0
 public BuildingTypeServicesTests()
 {
     this.context = InMemoryDatabase.GetDbContext();
     this.SeedData();
 }
 public RealEstateTypeServices(HomeHunterDbContext context)
 {
     this.context = context;
 }
Ejemplo n.º 26
0
 public VisitorSessionServices(HomeHunterDbContext context)
 {
     this.context = context;
 }
Ejemplo n.º 27
0
        private static async Task SeedNeighbourhoodsAsync(List <string> neighbourhoods, HomeHunterDbContext dbContext)
        {
            var neighbourhoodsFromDb  = dbContext.Neighbourhoods.ToList();
            var createdNeighbourhoods = new List <Neighbourhood>();

            foreach (var row in neighbourhoods)
            {
                var splitRow = row.Split(new string[] { ", " }, StringSplitOptions.None);
                var name     = splitRow[1];
                if (!neighbourhoodsFromDb.Any(x => x.Name == name))
                {
                    createdNeighbourhoods.Add(new Neighbourhood
                    {
                        Name      = name,
                        CreatedOn = DateTime.UtcNow,
                        CityId    = 1,
                    });
                }
            }

            await dbContext.Neighbourhoods.AddRangeAsync(createdNeighbourhoods);

            await dbContext.SaveChangesAsync();
        }
 public BuildingTypeServices(HomeHunterDbContext context)
 {
     this.context = context;
 }
Ejemplo n.º 29
0
 public StatisticsServicesTests()
 {
     this.context = this.GetDbContext();
     this.SeedData();
 }
 public NeighbourhoodServices(HomeHunterDbContext context)
 {
     this.context = context;
 }