Esempio n. 1
0
 public String Initialize()
 {
     using (var context = new StockExchangeDbContext())
     {
         new StockExchangeDbInitializer().InitializeDatabase(context);
         return "Database Initialized";
     }
 }
Esempio n. 2
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. 3
0
 public UnitOfWork()
 {
     StockExchangeDbContext = new StockExchangeDbContext();
     Stocks    = new StockRepository(StockExchangeDbContext);
     Exchanges = new ExchangeRepository(StockExchangeDbContext);
 }
Esempio n. 4
0
 public int SaveChanges()
 {
     return(StockExchangeDbContext.SaveChanges());
 }
Esempio n. 5
0
 public void Dispose()
 {
     StockExchangeDbContext.Dispose();
 }
Esempio n. 6
0
 public ExchangeRepository(StockExchangeDbContext context) : base(context)
 {
     Context = context;
 }
Esempio n. 7
0
        public static void InsertCompanies(Company company)
        {
            using (var context = new StockExchangeDbContext())
            {
                context.Database.ExecuteSqlInterpolated(@$ "EXEC dbo.InsertCompany @Isin={company.Isin}, @Name={company.Name}, @Sector={company.Sector.Name}, 
																				  @Industry={company.Industry.Name}, @EquityType={company.EquityType.Name},