Exemplo n.º 1
0
 public bool ThisCountryIsRegistered(Country country)
 {
     using (DB_PriceContext PriceContext = new DB_PriceContext())
     {
         CountryFee result = PriceContext.listCountryPrices.Find(country);
         return(result != null);
     }
 }
Exemplo n.º 2
0
        public void SetPricePerMin(int amount)
        {
            if (amount < 1)
            {
                throw new LessThanOneException();
            }
            CountryFee countryFee = new CountryFee();

            countryFee.Country     = this.actualCountry;
            countryFee.PricePerMin = amount;
            price_Min.SetPricePerMin(countryFee);
        }
Exemplo n.º 3
0
 public int GetPricePerMin(Country country)
 {
     using (DB_PriceContext PriceContext = new DB_PriceContext())
     {
         bool result = PriceContext.listCountryPrices.Any(cf => cf.Country == country);
         if (!result)
         {
             throw new Exception("Not Registered Country!");
         }
         CountryFee countryPrice = PriceContext.listCountryPrices.Single(cf => cf.Country == country);
         return(countryPrice.PricePerMin);
     }
 }
Exemplo n.º 4
0
        internal void PriceMinInitializationIfEmpty()
        {
            CountryFee CF = new CountryFee();

            CF.PricePerMin = 3;
            Country[] countryList = ListOfCountries();

            foreach (Country item in countryList)
            {
                if (!price_Min.ThisCountryIsRegistered(item))
                {
                    CF.Country = item;
                    price_Min.SetPricePerMin(CF);
                }
            }
        }
Exemplo n.º 5
0
 public void SetPricePerMin(CountryFee CF)
 {
     using (DB_PriceContext PriceContext = new DB_PriceContext())
     {
         bool result = PriceContext.listCountryPrices.Any(cf => cf.Country == CF.Country);
         if (!result)
         {
             PriceContext.listCountryPrices.Add(CF);
         }
         else
         {
             CountryFee countryPrice = PriceContext.listCountryPrices.Single(cf => cf.Country == CF.Country);
             countryPrice.PricePerMin = CF.PricePerMin;
         }
         PriceContext.SaveChanges();
     }
 }