Esempio n. 1
0
        public static void InsertCountryExchange(Country country, List <string> exchanges)
        {
            using (var context = new StockExchangeDbContext())
            {
                context.Countries.Add(country);
                context.SaveChanges();

                int countryId = country.CountryId;

                List <Exchange> newExchanges = new List <Exchange>();

                foreach (var exchange in exchanges)
                {
                    newExchanges.Add(new Exchange {
                        Name = exchange, CountryId = countryId
                    });
                }

                context.Exchanges.AddRange(newExchanges);
                context.SaveChanges();
            }
        }
Esempio n. 2
0
 public int SaveChanges()
 {
     return(StockExchangeDbContext.SaveChanges());
 }