Example #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);
            }
        }
Example #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);
        }
Example #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);
            }
        }
Example #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);
            }
        }
Example #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);
        }
Example #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();
            }
        }
 public TeamDataService(QdbContext qDb)
 {
     _qDb = qDb;
 }
Example #8
0
 public CollectibleQueryService(QdbContext qDb)
 {
     _qDb = qDb;
 }
 public GradeDataService(QdbContext qDb)
 {
     _qDb = qDb;
 }
 public ProductDataService(QdbContext qDb)
 {
     _qDb = qDb;
 }
Example #11
0
 public PersonDataService(QdbContext qDb)
 {
     _qDb = qDb;
 }
 public DatabaseService(QdbContext qDb)
 {
     _qDb = qDb;
 }
 public ContainerDataService(QdbContext qDb)
 {
     _qDb = qDb;
 }
Example #14
0
 public CollegeDataService(QdbContext qDb)
 {
     _qDb = qDb;
 }
Example #15
0
 public PersonQueryService(QdbContext qDb)
 {
     _qDb = qDb;
 }
Example #16
0
 public TeamQueryService(QdbContext qDb)
 {
     _qDb = qDb;
 }