private bool SaveDemo() { countryDemographyView1.DoValidate(); model = countryDemographyView1.GetDemo(); if (!model.IsValid() || !countryDemographyView1.IsValid()) { MessageBox.Show(Translations.ValidationError, Translations.ValidationErrorTitle); return false; } int userId = ApplicationData.Instance.GetUserId(); var demo = new DemoRepository(); demo.Save(model, userId); return true; }
private void doSave_Click(object sender, EventArgs e) { countryView1.DoValidate(); if (!country.IsValid()) { MessageBox.Show(Translations.ValidationError, Translations.ValidationErrorTitle); return; } countryDemographyView1.DoValidate(); countryStats = countryDemographyView1.GetDemo(); if (countryStats != null && (!countryStats.IsValid() || !countryDemographyView1.IsValid())) { MessageBox.Show(Translations.ValidationError, Translations.ValidationErrorTitle); return; } if (!adminLevelTypesControl1.HasAggregatingLevel()) { MessageBox.Show(Translations.MustMakeAggregatingLevel, Translations.ValidationErrorTitle); return; } int userId = ApplicationData.Instance.GetUserId(); demo.UpdateCountry(country, userId); if(countryStats != null) demo.Save(countryStats, userId); var selected = diseasePickerControl1.GetSelectedItems(); var available = diseasePickerControl1.GetUnselectedItems(); diseases.SaveSelectedDiseases(selected, true, userId); diseases.SaveSelectedDiseases(available, false, userId); OnClose(); }