private void Init(AdminLevelType type, IWizardStep step, bool demoOnly, int? cid) { countryDemoId = cid; isDemoOnly = demoOnly; locationType = type; prev = step; SettingsRepository settings = new SettingsRepository(); DemoRepository demo = new DemoRepository(); if (!isDemoOnly) demoDate = demo.GetCountryDemoRecent().DateDemographyData; if (!isSingleImport) { nextType = settings.GetNextLevel(locationType.LevelNumber); stepTitle = isDemoOnly ? Translations.UpdateDemography + " - " + locationType.DisplayName : Translations.ImportAdminLevels + locationType.DisplayName; importer = new AdminLevelDemoImporter(locationType, countryDemoId); } else stepTitle = Translations.Demography + " - " + locationType.DisplayName; updater = new AdminLevelDemoUpdater(locationType, countryDemoId); InitializeComponent(); }
void skipLink_ClickOverride() { int year = Convert.ToInt32(ConfigurationManager.AppSettings["SkipStartDemoYear"]); int userId = ApplicationData.Instance.GetUserId(); var c = demo.GetCountry(); c.Name = "Murkonia"; demo.UpdateCountry(c, userId); demo.Save(new CountryDemography { AdminLevelId = 1, GrowthRate = 9.5, DateDemographyData = new DateTime(year, 1, 1), TotalPopulation = 1, PopSac = 1, PercentAdult = 30, PercentPsac = 20, PercentSac = 50 }, userId); DiseaseRepository diseases = new DiseaseRepository(); var availableDiseases = diseases.GetAvailableDiseases(); diseases.SaveSelectedDiseases(availableDiseases, true, userId); settings.SetDiseasesReviewedStatus(); //Import stuff settings.Save(new AdminLevelType { DisplayName = "Village", LevelNumber = 3 }, userId); var adminLevels = settings.GetAllAdminLevels(); var region = adminLevels.FirstOrDefault(a => a.DisplayName == "Region"); region.DisplayName = "Province"; settings.Save(region, userId); var countryDemo = demo.GetCountryDemoRecent(); AdminLevelDemoImporter regImporter = new AdminLevelDemoImporter(region, countryDemo.Id); regImporter.ImportData("TestProvinces.xlsx", userId, false, false, 4, null, new DateTime(year, 1, 1)); AdminLevelDemoImporter disImporter = new AdminLevelDemoImporter(adminLevels.FirstOrDefault(a => a.DisplayName == "District"), countryDemo.Id); disImporter.ImportData("TestDistricts.xlsx", userId, true, true, 25, null, new DateTime(year, 1, 1)); AdminLevelDemoImporter vilImporter = new AdminLevelDemoImporter(adminLevels.FirstOrDefault(a => a.DisplayName == "Village"), countryDemo.Id); vilImporter.ImportData("TestVillages.xlsx", userId, true, false, 13, demo.GetAdminLevelById(3), new DateTime(year, 1, 1)); CheckStatus(); }