private void SeedDataFromXml()
        {
            textWriter.WriteLine("Seeding data from XML...");
            var xmlEmployeeReader = new XmlEmployeeReader();

            using (var dbContext = new DealershipDbContext())
            {
                var data = new DealershipData(dbContext);

                var employees = new DealershipRepository <Employee>(dbContext);
                var positions = new DealershipRepository <Position>(dbContext);
                var countries = new DealershipRepository <Country>(dbContext);
                var cities    = new DealershipRepository <City>(dbContext);
                var addresses = new DealershipRepository <Address>(dbContext);
                var shops     = new DealershipRepository <Shop>(dbContext);

                var employeeSeeder = new EmployeeSeeder(data, employees, positions, countries, cities, addresses, shops);

                var employeeSeedUtil = new EmployeeSeedUtil(xmlEmployeeReader, employeeSeeder);

                employeeSeedUtil.Seed();
            }

            textWriter.WriteLine("XML data seeded successfully!");
        }
        private void SeedDataFromMongo()
        {
            textWriter.WriteLine("Seeding data from Mongo...");
            string mongoDbConnectionString = Constants.MongoDbConnectionStringLocal;
            string mongoDbDatabaseName     = Constants.MongoDbDatabaseNameLocal;

            using (var dbContext = new DealershipDbContext())
            {
                var data = new DealershipData(dbContext);

                var vehicles     = new DealershipRepository <Vehicle>(dbContext);
                var brands       = new DealershipRepository <Brand>(dbContext);
                var fuels        = new DealershipRepository <Fuel>(dbContext);
                var vehicleTypes = new DealershipRepository <VehicleType>(dbContext);

                var mongoDbSeeder = new MongoDbSeeder(
                    mongoDbConnectionString,
                    mongoDbDatabaseName,
                    data,
                    vehicles,
                    brands,
                    fuels,
                    vehicleTypes
                    );
                if (!mongoDbSeeder.IsDataSeeded())
                {
                    mongoDbSeeder.SeedData();
                }
            }

            textWriter.WriteLine("Mongo data seeded successfully!");
        }
        private static void ProcessZipFiles()
        {
            using (var dbContext = new DealershipDbContext())
            {
                var data      = new DealershipData(dbContext);
                var employees = new DealershipRepository <Employee>(dbContext);
                var sales     = new DealershipRepository <Sale>(dbContext);
                var vehicles  = new DealershipRepository <Vehicle>(dbContext);
                var shops     = new DealershipRepository <Shop>(dbContext);

                SeedingSQLDBFromZip seedingSQLDBFromZip = new SeedingSQLDBFromZip(data, employees, shops, sales, vehicles);

                var processor = new ZipUnpacker();
                processor.Unpack(Constants.PathToZipFile, Constants.PathToUnzip);

                var          matchingDirectories = Utility.GetDirectoriesByPattern(Constants.PathToUnzippedFiles);
                ReportReader reportReader        = new ReportReader(seedingSQLDBFromZip, data);
                reportReader.ParseExcelData(matchingDirectories);
            }
        }
예제 #4
0
        public async Task <string> Handle(CreateDealershipCommand request, CancellationToken cancellationToken)
        {
            try
            {
                var dealership = new Dealership
                {
                    Name     = request.Dealership.Name,
                    Address1 = request.Dealership.Address1,
                    City     = request.Dealership.City,
                    State    = request.Dealership.State
                };

                await DealershipData.CreateDealership(dealership);

                return($"{request.RequestId}: Dealership {dealership.Name} created successfully.");
            }
            catch (Exception ex)
            {
                return($"{request.RequestId}: Dealership creation failed. Error: {ex.Message}");
            }
        }
예제 #5
0
 public override void Process()
 {
     var service = new DealershipService();
     _dealershipData = service.GetDealershipData(_id, _uri);
     if (Monitor.TryEnter(theLock, 300))
     {
         try
         {
             dealershipDataSet.Add(_dealershipData);
         }
         finally
         {
             Monitor.Exit(theLock);
         }
     }
     else
     {
         throw new TimeoutException();
     }
 }
예제 #6
0
 private void GenerateDummyDataList(int listSize)
 {
     dummyDataList = new List<DealershipData>();
     for(var i = 0; i < listSize; i++)
     {
         var dealershipData = new DealershipData { DealershipIdentifier = i.ToString(), AvailableStock = i, TotalSales = i * 10000 };
         dummyDataList.Add(dealershipData);
     }
 }
예제 #7
0
 public async Task <IEnumerable <Car> > Handle(GetCarsByDealershipQuery request, CancellationToken cancellationToken) =>
 await DealershipData.GetCarsByDealership(request.DealershipId);
예제 #8
0
 public async Task <Dealership> Handle(GetDealershipQuery request, CancellationToken cancellationToken) =>
 await DealershipData.GetDealershipById(request.DealershipId);
예제 #9
0
 public async Task <IEnumerable <Dealership> > Handle(GetAllDealershipsQuery request, CancellationToken cancellationToken) =>
 await DealershipData.GetAllDealerships();