private void OnDelete()
        {
            if (deletedCountriesIndex.Count < CountriesDB.Countries.Count)
            {
                if (deletedCountriesIndex.Count + 1 == CountriesDB.Countries.Count &&
                    MessageBox.Show($"Do you really want to delete {CountriesDB.Countries[currCountryIndex].CountryName}?", "Please select", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                {
                    deletedCountriesIndex.Add(currCountryIndex);
                    CountriesDB.Countries[currCountryIndex].IsDeleted = true;

                    ICountry test = CountryFactory.CreateEmptyCountry(@"Images\noImage.png");

                    CurrCountry.CountryName = test.CountryName;
                    CurrCountry.CapitalName = test.CapitalName;
                    CurrCountry.CountryInfo = test.CountryInfo;
                    CurrCountry.CountryFlag = test.CountryFlag;
                }
                else if (MessageBox.Show($"Do you really want to delete {CountriesDB.Countries[currCountryIndex].CountryName}?", "Please select", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                {
                    deletedCountriesIndex.Add(currCountryIndex);
                    CountriesDB.Countries[currCountryIndex].IsDeleted = true;
                    OnNext();
                }
            }
        }
        public void CreateEmptyCountryWithParameterMethod_ShouldMakeNoNEmptyCountry_WhenCalled()
        {
            ICountry emptyCountry = CountryFactory.CreateEmptyCountry(@"\Images\Countries\italy.png");

            Assert.AreEqual(emptyCountry.CountryName, "");
            Assert.AreEqual(emptyCountry.CapitalName, "");
            Assert.AreEqual(emptyCountry.CountryInfo, "");
            Assert.AreEqual(emptyCountry.CountryPath, @"\Images\Countries\italy.png");
        }
        public void CreateEmptyCountryWithoutParameterMethod_ShouldMakeEmptyCountry_WhenCalled()
        {
            ICountry emptyCountry = CountryFactory.CreateEmptyCountry();

            Assert.AreEqual(emptyCountry.CountryName, "");
            Assert.AreEqual(emptyCountry.CapitalName, "");
            Assert.AreEqual(emptyCountry.CountryInfo, "");
            Assert.AreEqual(emptyCountry.CountryPath, "");
        }
        public static ICountry ResetCountry(ICountry country)
        {
            ICountry reset = CountryFactory.CreateEmptyCountry();

            country.CountryName = reset.CountryName;
            country.CapitalName = reset.CapitalName;
            country.CountryInfo = reset.CountryInfo;
            country.CountryPath = reset.CountryPath;

            return(reset);
        }
Beispiel #5
0
        private void OnSave()
        {
            if (currCountry.CountryName != "" &&
                currCountry.CapitalName != "" &&
                currCountry.CountryInfo != "" &&
                currCountry.CountryPath != "")
            {
                ICountry country = CountryFactory.CreateEmptyCountry();

                country.CountryName = currCountry.CountryName;
                country.CapitalName = currCountry.CapitalName;
                country.CountryInfo = currCountry.CountryInfo;
                country.CountryPath = currCountry.CountryPath;

                CountriesDB.Countries.Add(country);
                //Countries.Add(country);

                currCountry = HelperFunction.ResetCountry(currCountry);

                MessageBox.Show($"Country added successfully!");
            }
        }