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); } }
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); }
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); } }
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); } }
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); }
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; }
public CollectibleQueryService(QdbContext qDb) { _qDb = qDb; }
public GradeDataService(QdbContext qDb) { _qDb = qDb; }
public ProductDataService(QdbContext qDb) { _qDb = qDb; }
public PersonDataService(QdbContext qDb) { _qDb = qDb; }
public DatabaseService(QdbContext qDb) { _qDb = qDb; }
public ContainerDataService(QdbContext qDb) { _qDb = qDb; }
public CollegeDataService(QdbContext qDb) { _qDb = qDb; }
public PersonQueryService(QdbContext qDb) { _qDb = qDb; }
public TeamQueryService(QdbContext qDb) { _qDb = qDb; }