public bool ThisCountryIsRegistered(Country country) { using (DB_PriceContext PriceContext = new DB_PriceContext()) { CountryFee result = PriceContext.listCountryPrices.Find(country); return(result != null); } }
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); } }
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(); } }