예제 #1
0
 public RepliesService(
     CarZoneDbContext dbContext,
     IUsersService usersService)
 {
     this.dbContext    = dbContext;
     this.usersService = usersService;
 }
예제 #2
0
 public CommentsService(
     CarZoneDbContext dbContext,
     IUsersService usersService)
 {
     this.dbContext    = dbContext;
     this.usersService = usersService;
 }
예제 #3
0
        public async Task SeedAsync(CarZoneDbContext dbContext, IServiceProvider serviceProvider)
        {
            if (dbContext.Exteriors.Any())
            {
                return;
            }

            var exteriors = new List <string>()
            {
                "LED headlights",
                "Summer wheels",
                "Xenon lights",
                "Metallic",
                "Heated wipers",
                "Panoramic sunroof",
                "Roof railing",
                "Rollbars",
                "Spoilers",
                "Towbar",
                "Halogen headlights",
                "Shibedah",
            };

            foreach (var exteriorName in exteriors)
            {
                await dbContext.Exteriors.AddAsync(new Exterior { Name = exteriorName });
            }
        }
예제 #4
0
        public async Task SeedAsync(CarZoneDbContext dbContext, IServiceProvider serviceProvider)
        {
            if (dbContext.Safeties.Any())
            {
                return;
            }

            var safeties = new List <string>()
            {
                "GPS tracking system",
                "Automatic stability control",
                "Adaptive headlights",
                "Anti-lock braking system (ABS)",
                "Airbags - Rear",
                "Airbags - Front",
                "Airbags - Side",
                "Electric brake force distribution",
                "Electronic stabilization program (ESP)",
                "Tire pressure control",
                "Parktronic",
                "ISOFIX system",
                "Dynamic stability system",
                "Slip protection system",
                "Brake drying system",
                "Distance control system",
                "Descent control system",
                "Brake assist system",
            };

            foreach (var safetyName in safeties)
            {
                await dbContext.Safeties.AddAsync(new Safety { Name = safetyName });
            }
        }
예제 #5
0
 public UsersService(
     CarZoneDbContext dbContext,
     UserManager <User> userManager)
 {
     this.dbContext   = dbContext;
     this.userManager = userManager;
 }
예제 #6
0
        public async Task SeedAsync(CarZoneDbContext dbContext, IServiceProvider serviceProvider)
        {
            if (dbContext == null)
            {
                throw new ArgumentNullException(nameof(dbContext));
            }

            if (serviceProvider == null)
            {
                throw new ArgumentNullException(nameof(serviceProvider));
            }

            var logger = serviceProvider.GetService <ILoggerFactory>().CreateLogger(typeof(DbContextSeeder));

            var seeders = new List <ISeeder>
            {
                new DataSeeder(),
                new RolesSeeder(),
                new ComfortSeeder(),
                new ExteriorSeeder(),
                new ProtectionSeeder(),
                new SafetySeeder(),
                new BrandSeeder(),
            };

            foreach (var seeder in seeders)
            {
                await seeder.SeedAsync(dbContext, serviceProvider);

                await dbContext.SaveChangesAsync();

                logger.LogInformation($"Seeder {seeder.GetType().Name} done.");
            }
        }
예제 #7
0
 public IdentityService(
     UserManager <User> userManager,
     CarZoneDbContext data,
     IUsersService usersService)
 {
     this.userManager  = userManager;
     this.data         = data;
     this.usersService = usersService;
 }
예제 #8
0
 public AdvertisementsService(
     CarZoneDbContext dbContext,
     IUsersService usersService,
     ICarsService carsService,
     IImagesService imagesService)
 {
     this.dbContext     = dbContext;
     this.usersService  = usersService;
     this.carsService   = carsService;
     this.imagesService = imagesService;
 }
예제 #9
0
        public async Task SeedAsync(CarZoneDbContext dbContext, IServiceProvider serviceProvider)
        {
            var userManager = serviceProvider.GetRequiredService <UserManager <User> >();

            // creating first user;
            var users = await userManager.Users.AnyAsync();

            if (!users)
            {
                await CreateUser(userManager, FullName, UserName, Email);
            }
        }
예제 #10
0
 public CarsService(
     CarZoneDbContext dbContext,
     IUsersService usersService,
     ICarComfortsService carComfortsService,
     ICarExteriorsService carExteriorsService,
     ICarProtectionsService carProtectionsService,
     ICarSafetiesService carSafetiesService)
 {
     this.dbContext             = dbContext;
     this.usersService          = usersService;
     this.carComfortsService    = carComfortsService;
     this.carExteriorsService   = carExteriorsService;
     this.carProtectionsService = carProtectionsService;
     this.carSafetiesService    = carSafetiesService;
 }
예제 #11
0
        public async Task SeedAsync(CarZoneDbContext dbContext, IServiceProvider serviceProvider)
        {
            if (dbContext.Comforts.Any())
            {
                return;
            }

            var comforts = new List <string>()
            {
                "Auto Start Stop function",
                "Bluetooth / Handsfree system",
                "DVD, TV",
                "Steptronic, Tiptronic",
                "USB, audio/video, IN/AUX",
                "Adaptive air suspension",
                "Keyless start",
                "Differential Lock",
                "Board computer",
                "Fast / Slow transmission",
                "Light sensor",
                "Electric Mirrors",
                "Electric Windows",
                "Electrical suspension adjustment",
                "Electrical seat adjustment",
                "Electrical power steering",
                "Air conditioner",
                "Climatronic",
                "Multifunction steering wheel",
                "Navigation",
                "Stove",
                "Heated front window",
                "Seat heating",
                "Steering wheel adjustment",
                "Rain sensor",
                "Power steering",
                "Headlamp wash system",
                "Speed control system (autopilot)",
                "Stereo",
                "Filter for hard particles",
                "Refrigerator",
            };

            foreach (var comfortName in comforts)
            {
                await dbContext.Comforts.AddAsync(new Comfort { Name = comfortName });
            }
        }
예제 #12
0
        public async Task SeedAsync(CarZoneDbContext dbContext, IServiceProvider serviceProvider)
        {
            if (dbContext.Protections.Any())
            {
                return;
            }

            var protections = new List <string>()
            {
                "OFFROAD package",
                "Alarm",
                "Armored",
                "Immobilizer",
                "Casco",
                "Winch",
                "Reinforced glass",
                "Central locking",
            };

            foreach (var protectionName in protections)
            {
                await dbContext.Protections.AddAsync(new Protection { Name = protectionName });
            }
        }
예제 #13
0
 public SafetiesService(CarZoneDbContext dbContext)
 {
     this.dbContext = dbContext;
 }
예제 #14
0
 public CarComfortsService(CarZoneDbContext dbContext)
 {
     this.dbContext = dbContext;
 }
예제 #15
0
        public async Task SeedAsync(CarZoneDbContext dbContext, IServiceProvider serviceProvider)
        {
            var roleManager = serviceProvider.GetRequiredService <RoleManager <Role> >();

            await SeedRoleAsync(roleManager, AdministratorRoleName);
        }
예제 #16
0
 public CarProtectionsService(CarZoneDbContext dbContext)
 {
     this.dbContext = dbContext;
 }
예제 #17
0
 public ModelsService(CarZoneDbContext data)
 {
     this.dbContext = data;
 }
예제 #18
0
 public ExteriorsService(CarZoneDbContext dbContext)
 {
     this.dbContext = dbContext;
 }
예제 #19
0
 public ImagesService(CarZoneDbContext dbContext)
 {
     this.dbContext = dbContext;
 }
예제 #20
0
 public BrandsService(CarZoneDbContext dbContext)
 {
     this.dbContext = dbContext;
 }
예제 #21
0
        public async Task SeedAsync(CarZoneDbContext dbContext, IServiceProvider serviceProvider)
        {
            if (dbContext.Brands.Any())
            {
                return;
            }

            var brands = new List <string>()
            {
                // A
                "AC",
                "Abarth",
                "Acura",
                "Aixam",
                "Alfa Romeo",
                "Alpina",
                "Aro",
                "Asia",
                "Aston Martin",
                "Audi",
                "Austin",

                // B
                "BMW",
                "Bentley",
                "Berliner",
                "Bertone",
                "Borgward",
                "Brilliance",
                "Bugatti",
                "Buick",

                // C
                "Cadillac",
                "Chevrolet",
                "Chrysler",
                "Citroen",
                "Corvette",
                "Cupra",

                // D
                "DS",
                "Dacia",
                "Daewoo",
                "Daihatsu",
                "Daimler",
                "Datsun",
                "Dkw",
                "Dodge",
                "Dr",

                // E
                "Eagle",

                // F
                "FSO",
                "Ferrari",
                "Fiat",
                "Ford",

                // G
                "GOUPIL",
                "Gaz",
                "Geo",
                "Gmc",
                "Great Wall",

                // H
                "Haval",
                "Hinkel",
                "Hillman",
                "Honda",
                "Hyummer",
                "Hyundai",

                // I
                "Ifa",
                "Infiniti",
                "Innocenti",
                "Isuzu",
                "Iveco",

                // J
                "JAS",
                "Jaguar",
                "Jeep",
                "Jpx",

                // K
                "Kia",

                // L
                "Lada",
                "Laforza",
                "Lamborghini",
                "Lancia",
                "Land Rover",
                "Landwind",
                "Lexus",
                "Lifan",
                "Lincoln",
                "Lotus",

                // M
                "MG",
                "Mahindra",
                "Maserati",
                "Matra",
                "Maybach",
                "Mazda",
                "McLaren",
                "Mercedes-Benz",
                "Mercury",
                "Mg",
                "Microcar",
                "Mini",
                "Mitsubishi",
                "Morgan",
                "Moskvich",

                // N
                "Nissan",

                // O
                "Oldmobile",
                "Opel",

                // P
                "Perodua",
                "Peugeot",
                "Pgo",
                "Plymouth",
                "Polonez",
                "Pontiac",
                "Porsche",
                "Proton",

                // R
                "Renault",
                "Rolls-Royce",
                "Rover",

                // S
                "SECMA",
                "SH auto",
                "Saab",
                "Samand",
                "Santana",
                "Saturn",
                "Scion",
                "Seat",
                "Shatenet",
                "Shuanghuan",
                "Simca",
                "Skoda",
                "Smart",
                "Ssang yong",
                "Subaru",
                "Suzuki",

                // T
                "Talbot",
                "Tata",
                "Tavria",
                "Tazzari",
                "Tempo",
                "Terberg",
                "Tesla",
                "Tofas",
                "Toyota",
                "Trabant",
                "Triumph",

                // U
                "Uaz",

                // V
                "VROMOS",
                "VW",
                "Volga",
                "Volvo",

                // W
                "Warszawa",
                "Wartburg",
                "Wiesmann",

                // X
                "Xinkai",
                "Xinshun",

                // Z
                "Zastava",
                "Zaz",

                //
                "Other",
            };

            foreach (var brandName in brands)
            {
                await dbContext.Brands.AddAsync(new Brand { Name = brandName });
            }
        }