public JsonModularHousehold GetJson()
        {
            JsonModularHousehold jec = new JsonModularHousehold(Name,
                                                                Description, Guid, CreationType, DeviceSelection?.GetJsonReference(),
                                                                EnergyIntensityType, Vacation?.GetJsonReference());

            foreach (var person in Persons)
            {
                jec.Persons.Add(person.GetJson());
            }

            foreach (var householdTrait in Traits)
            {
                jec.Traits.Add(householdTrait.GetJson());
            }

            foreach (var householdTag in ModularHouseholdTags)
            {
                jec.HouseholdTags.Add(householdTag.Tag.GetJsonReference());
            }
            return(jec);
        }
        public void ImportFromJsonTemplate([NotNull] JsonModularHousehold jsonHH, [NotNull] Simulator sim)
        {
            Logger.Info("Adjusting values based on Json-Data for " + jsonHH.Name);
            Name         = jsonHH.Name;
            Description  = jsonHH.Description ?? "";
            CreationType = jsonHH.CreationType;
            Guid         = jsonHH.Guid;
            if (jsonHH.DeviceSelection != null)
            {
                var devsel = sim.DeviceSelections.FindByGuid(jsonHH.DeviceSelection.Guid);
                DeviceSelection = devsel ?? throw new LPGException("Could not find the device selection with the guid " + jsonHH.DeviceSelection.Guid + " while importing households");
            }
            EnergyIntensityType = jsonHH.EnergyIntensityType;
            if (jsonHH.Vacation != null)
            {
                var vac = sim.Vacations.FindByGuid(jsonHH.Vacation.Guid);
                Vacation = vac;
            }
            //persons
            SynchronizeList(Persons, jsonHH.Persons, out var personsToCreate);
            foreach (var personJson in personsToCreate)
            {
                var person = sim.Persons.FindByGuid(personJson.Person.Guid);
                if (person == null)
                {
                    throw new LPGException("Person with the guid " + personJson.Person.Guid + " and the name " + personJson.Person.Name + " could not be found in the database.");
                }

                TraitTag tag = null;
                if (personJson.TraitTag != null)
                {
                    tag = sim.TraitTags.FindByGuid(personJson.TraitTag.Guid);
                }
                var hhp = AddPerson(person, tag);
                if (hhp != null)
                {
                    hhp.Guid = personJson.Guid;
                }
            }

            foreach (var person in Persons)
            {
                var jtp = jsonHH.Persons.Single(x => person.Guid == x.Guid);
                person.SynchronizeDataFromJson(jtp, sim);
            }

            //traits
            SynchronizeList(Traits, jsonHH.Traits, out var traitsToCreate);
            foreach (var traitJson in traitsToCreate)
            {
                var trait = sim.HouseholdTraits.FindByGuid(traitJson.HouseholdTrait?.Guid);
                if (trait == null)
                {
                    throw new LPGException("TraitTag " + traitJson.HouseholdTrait + " could not be found in the database.");
                }

                Person person = null;
                if (traitJson.DstPerson != null)
                {
                    person = sim.Persons.FindByGuid(traitJson.DstPerson.Guid);
                    if (person == null)
                    {
                        throw new LPGException("Person " + traitJson.DstPerson + " was not found");
                    }
                }
                var t = AddTrait(trait, traitJson.AssignType, person);
                if (t == null)
                {
                    throw new LPGException("Could not add new trait");
                }
                t.Guid = traitJson.Guid;
            }

            foreach (var trait in Traits)
            {
                var jtp = jsonHH.Traits.Single(x => trait.Guid == x.Guid);
                trait.SynchronizeDataFromJson(jtp, sim);
            }

            //traits
            SynchronizeList(ModularHouseholdTags, jsonHH.HouseholdTags, out var tagsToCreate);
            foreach (var tagJsonRef in tagsToCreate)
            {
                var tag = sim.HouseholdTags.FindByGuid(tagJsonRef.Guid);
                if (tag == null)
                {
                    throw new LPGException("Tag " + tagJsonRef.Name + " could not be found in the database.");
                }
                AddHouseholdTag(tag);
            }

            foreach (var trait in Traits)
            {
                var jtp = jsonHH.Traits.Single(x => trait.Guid == x.Guid);
                trait.SynchronizeDataFromJson(jtp, sim);
            }
            SaveToDB();
        }