Ejemplo n.º 1
0
        public static int SeedCollege(DbContextOptions <QdbContext> options, string identifier, string name, string nickname)
        {
            using (var context = new QdbContext(options))
            {
                var college = context.Colleges.SingleOrDefault(x => x.Identifier == identifier);

                if (college == null)
                {
                    college = AddCollege(context, identifier, name, nickname);
                }

                return(college.Id);
            }
        }
Ejemplo n.º 2
0
        private static College AddCollege(QdbContext context, string identifier, string name, string nickname)
        {
            var college = new College
            {
                Identifier = identifier,
                Name       = name,
                Nickname   = nickname
            };

            context.Colleges.Add(college);
            context.SaveChanges();

            return(college);
        }
Ejemplo n.º 3
0
        public static int SeedProduct(DbContextOptions <QdbContext> options, string productIdentifier)
        {
            using (var context = new QdbContext(options))
            {
                var product = context.Products.SingleOrDefault(x => x.Identifier == productIdentifier);

                if (product == null)
                {
                    throw new Exception("Product already exists");
                }

                product = AddProduct(context, productIdentifier, ProductStatusCodeService.ForSale.Id);

                return(product.Id);
            }
        }
Ejemplo n.º 4
0
        public static int SeedTeam(DbContextOptions <QdbContext> options, string identifier, string city, string nickname, string leagueIdentifier, bool notableFlag)
        {
            using (var context = new QdbContext(options))
            {
                var league = LeagueCodeService.Select(leagueIdentifier);

                var team = context.Teams.SingleOrDefault(x => x.Identifier == identifier);
                if (team != null)
                {
                    throw new Exception("Team already exists");
                }

                team = AddTeam(context, identifier, city, nickname, league, notableFlag);

                return(team.Id);
            }
        }
Ejemplo n.º 5
0
        private static Team AddTeam(QdbContext context, string identifier, string city, string nickname, League league, bool notableFlag)
        {
            var team = new Team
            {
                Identifier  = identifier,
                City        = city,
                Nickname    = nickname,
                SportId     = league.SportId,
                LeagueId    = league.Id,
                NotableFlag = notableFlag
            };

            context.Teams.Add(team);
            context.SaveChanges();

            return(team);
        }
Ejemplo n.º 6
0
        public static void SeedCodeValues(DbContextOptions <QdbContext> options)
        {
            using (var context = new QdbContext(options))
            {
                if (context.CollectibleStatuses.Count() > 0)
                {
                    return;
                }

                foreach (var cardType in CardTypeCodeService.Select())
                {
                    context.CardTypes.Add(cardType);
                }
                foreach (var collectibleStatus in CollectibleStatusCodeService.Select())
                {
                    context.CollectibleStatuses.Add(collectibleStatus);
                }
                foreach (var collectibleType in CollectibleTypeCodeService.Select())
                {
                    context.CollectibleTypes.Add(collectibleType);
                }
                foreach (var league in LeagueCodeService.Select())
                {
                    context.Leagues.Add(league);
                }
                foreach (var productStatus in ProductStatusCodeService.Select())
                {
                    context.ProductStatuses.Add(productStatus);
                }
                foreach (var sport in SportCodeService.Select())
                {
                    context.Sports.Add(sport);
                }

                context.SaveChanges();
            }
        }
Ejemplo n.º 7
0
 public TeamDataService(QdbContext qDb)
 {
     _qDb = qDb;
 }
Ejemplo n.º 8
0
 public CollectibleQueryService(QdbContext qDb)
 {
     _qDb = qDb;
 }
Ejemplo n.º 9
0
 public GradeDataService(QdbContext qDb)
 {
     _qDb = qDb;
 }
Ejemplo n.º 10
0
 public ProductDataService(QdbContext qDb)
 {
     _qDb = qDb;
 }
Ejemplo n.º 11
0
 public PersonDataService(QdbContext qDb)
 {
     _qDb = qDb;
 }
Ejemplo n.º 12
0
 public DatabaseService(QdbContext qDb)
 {
     _qDb = qDb;
 }
 public ContainerDataService(QdbContext qDb)
 {
     _qDb = qDb;
 }
Ejemplo n.º 14
0
 public CollegeDataService(QdbContext qDb)
 {
     _qDb = qDb;
 }
Ejemplo n.º 15
0
 public PersonQueryService(QdbContext qDb)
 {
     _qDb = qDb;
 }
Ejemplo n.º 16
0
 public TeamQueryService(QdbContext qDb)
 {
     _qDb = qDb;
 }