public String Initialize()
 {
     using (var context = new StockExchangeDbContext())
     {
         new StockExchangeDbInitializer().InitializeDatabase(context);
         return "Database Initialized";
     }
 }
Exemple #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();
            }
        }
Exemple #3
0
 public UnitOfWork()
 {
     StockExchangeDbContext = new StockExchangeDbContext();
     Stocks    = new StockRepository(StockExchangeDbContext);
     Exchanges = new ExchangeRepository(StockExchangeDbContext);
 }
Exemple #4
0
 public int SaveChanges()
 {
     return(StockExchangeDbContext.SaveChanges());
 }
Exemple #5
0
 public void Dispose()
 {
     StockExchangeDbContext.Dispose();
 }
 public ExchangeRepository(StockExchangeDbContext context) : base(context)
 {
     Context = context;
 }
Exemple #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},