コード例 #1
0
        public static void EnsureSeedData(this BGScreenerContext context)
        {
            if (context.AllMigrationsApplied())
            {
                if (!context.Currency.Any())
                {
                    var euro = context.Currency.Add(new CurrencyDTO()
                    {
                        IsoCode = "EUR"
                    }).Entity;
                    var real = context.Currency.Add(new CurrencyDTO()
                    {
                        IsoCode = "BRL"
                    }).Entity;
                    var dolar = context.Currency.Add(new CurrencyDTO()
                    {
                        IsoCode = "USD"
                    }).Entity;

                    var germany = context.Country.Add(new CountryDTO()
                    {
                        Name = "Germany", Currency = euro
                    }).Entity;
                    var brasil = context.Country.Add(new CountryDTO()
                    {
                        Name = "Brasil", Currency = real
                    }).Entity;
                    var usa = context.Country.Add(new CountryDTO()
                    {
                        Name = "USA", Currency = dolar
                    }).Entity;

                    var glomhaven = context.Boardgame.Add(new BoardgameDTO()
                    {
                        Name = "Gloomhaven"
                    }).Entity;
                    var seventhContinent = context.Boardgame.Add(new BoardgameDTO()
                    {
                        Name = "7Th Continent"
                    }).Entity;
                    var mariposas = context.Boardgame.Add(new BoardgameDTO()
                    {
                        Name = "Mariposas"
                    }).Entity;

                    var fanazyWelt = context.Store.Add(new StoreDTO()
                    {
                        Name = "FantazyWelt", Country = germany, Boardgames = new List <BoardgameDTO>()
                        {
                            glomhaven, seventhContinent
                        }
                    }).Entity;
                    var zatu = context.Store.Add(new StoreDTO()
                    {
                        Name = "ZATU", Country = germany, Boardgames = new List <BoardgameDTO>()
                        {
                            mariposas
                        }
                    }).Entity;

                    glomhaven.Stores = new List <StoreDTO>()
                    {
                        fanazyWelt
                    };
                    seventhContinent.Stores = new List <StoreDTO>()
                    {
                        fanazyWelt
                    };
                    mariposas.Stores = new List <StoreDTO>()
                    {
                        zatu
                    };

                    //var ex1 = context.ExchangeRate.Add(new DbcExchangeRate() { FromCurrencyId = 1, ToCurrencyId = 2, Rate = 6.52m }).Entity;
                    //var ex2 = context.ExchangeRate.Add(new DbcExchangeRate() { FromCurrencyId = 1, ToCurrencyId = 3, Rate = 1.21m }).Entity;
                    //var ex3 = context.ExchangeRate.Add(new DbcExchangeRate() { FromCurrencyId = 2, ToCurrencyId = 1, Rate = 0.15m }).Entity;
                    //var ex4 = context.ExchangeRate.Add(new DbcExchangeRate() { FromCurrencyId = 2, ToCurrencyId = 3, Rate = 0.19m }).Entity;
                    //var ex5 = context.ExchangeRate.Add(new DbcExchangeRate() { FromCurrencyId = 3, ToCurrencyId = 1, Rate = 0.83m }).Entity;
                    //var ex6 = context.ExchangeRate.Add(new DbcExchangeRate() { FromCurrencyId = 3, ToCurrencyId = 2, Rate = 5.38m }).Entity;

                    //var historicalPrice = context.HistoricalPrice.Add(new DbcHistoricalPrice() { BoardGame = glomhaven, Store = fanazyWelt, DateTime = DateTime.UtcNow }).Entity;

                    context.SaveChanges();
                }
            }
        }
コード例 #2
0
 public CountryService(BGScreenerContext countryRepository, IMapper mapper)
 {
     _repository = countryRepository;
     _mapper     = mapper;
 }
コード例 #3
0
 public HistoricalPriceService(BGScreenerContext repository)
 {
     _repository = repository;
 }
コード例 #4
0
 public StoreService(BGScreenerContext storeRepository, IMapper mapper)
 {
     _repository = storeRepository;
     _mapper     = mapper;
 }
コード例 #5
0
 public CurrencyService(BGScreenerContext currencyRepository, IMapper mapper)
 {
     _repository = currencyRepository;
     _mapper     = mapper;
 }
コード例 #6
0
 public ExchangeRateService(BGScreenerContext repository)
 {
     _repository = repository;
 }
コード例 #7
0
 public BoardgameService(BGScreenerContext repository, IMapper mapper)
 {
     _repository = repository;
     _mapper     = mapper;
 }