private static void MakeNewAdjustedRoute([NotNull] Simulator sim,
                                                 [NotNull] TravelRouteSetEntry oldTravelRouteSetEntry,
                                                 int adjustingDistances,
                                                 [CanBeNull] string modRouteKey,
                                                 [NotNull] TransportationDistanceModifier modifier,
                                                 [NotNull] TravelRouteSet adjustedTravelrouteset)
        {
            var         oldRoute = oldTravelRouteSetEntry.TravelRoute;
            TravelRoute newRoute = new TravelRoute(null,
                                                   sim.ConnectionString,
                                                   oldRoute.Name + " adjustment " + adjustingDistances,
                                                   oldRoute.Description,
                                                   oldRoute.SiteA,
                                                   oldRoute.SiteB,
                                                   Guid.NewGuid().ToStrGuid(),
                                                   oldRoute.RouteKey);

            newRoute.SaveToDB();
            sim.TravelRoutes.It.Add(newRoute);
            foreach (var step in oldRoute.Steps)
            {
                double distance = step.Distance;
                if (step.StepKey?.ToLower(CultureInfo.InvariantCulture) == modRouteKey)
                {
                    distance = modifier.NewDistanceInMeters;
                }
                newRoute.AddStep(step.Name, step.TransportationDeviceCategory, distance, step.StepNumber, step.StepKey, false);
            }


            newRoute.SaveToDB();
            //Logger.Info("Adjusted route " + newRoute.Name);
            adjustedTravelrouteset.AddRoute(newRoute);
        }
        public void HouseGeneratorTestWithPersonSpecAndTransport()
        {
            //setup
            Logger.Get().StartCollectingAllMessages();
            using (WorkingDir workingDir = new WorkingDir(Utili.GetCurrentMethodAndClass())) {
                using (DatabaseSetup db = new DatabaseSetup(Utili.GetCurrentMethodAndClass())) {
                    Simulator  sim = new Simulator(db.ConnectionString);
                    WorkingDir wd  = workingDir;

                    //housedata
                    HouseData houseData = new HouseData(Guid.NewGuid().ToStrGuid(),
                                                        "HT01", 10000, 1000, "HouseGeneratorJobHouse");
                    var chargingStationSet = sim.ChargingStationSets
                                             .SafeFindByName("Charging At Home with 03.7 kW, output results to Car Electricity")
                                             .GetJsonReference();
                    Logger.Info("Using charging station " + chargingStationSet);
                    var transportationDeviceSet = sim.TransportationDeviceSets[0].GetJsonReference();
                    var travelRouteSet          = sim.TravelRouteSets[0].GetJsonReference();
                    var work          = new TransportationDistanceModifier("Work", "Car", 0);
                    var entertainment = new TransportationDistanceModifier("Entertainment", "Car", 12000);
                    List <TransportationDistanceModifier> tdm = new List <TransportationDistanceModifier>
                    {
                        work, entertainment
                    };
                    var householdData = new HouseholdData(Guid.NewGuid().ToString(),
                                                          "blub", chargingStationSet, transportationDeviceSet,
                                                          travelRouteSet, tdm, HouseholdDataSpecificationType.ByPersons);
                    houseData.Households.Add(householdData);
                    var persons = new List <PersonData> {
                        new PersonData(30, Gender.Male)
                    };
                    householdData.HouseholdDataPersonSpec = new HouseholdDataPersonSpecification(persons);
                    HouseCreationAndCalculationJob houseJob =
                        new HouseCreationAndCalculationJob("present", "2019", "trafokreis",
                                                           HouseDefinitionType.HouseData);
                    houseJob.House = houseData;
                    MakeAndCalculateHouseJob(houseJob, sim, wd, db);
                }
            }
        }