static void InsertStartersToDB(List <Starters> starters) { try { using (var context = new BBStats4Context()) { starters.ForEach(x => context.Starters.Add(new Starters { StarterName = x.StarterName, TeamName = x.TeamName, VarEra = x.VarEra, VarIps = x.VarIps, VarKo9 = x.VarKo9, VarBb9 = x.VarBb9, VarFip = x.VarFip, FanId = x.FanId })); context.SaveChanges(); PrintSystemInfo($"{context.Starters.Count()} " + $"Starters added to the Starter Table."); } } catch (Exception ex) { Console.WriteLine($"Failed to open context."); Console.WriteLine($"{ex}"); } }
static List <Starters> GetStartersFromDB() { using (var context = new BBStats4Context()) { return(context.Starters.ToList()); } }
static void FirstInsertIntoStarterBuff() { using (var context = new BBStats4Context()) { // strikeout artist = ko9 > 8.5; // groundball machine = fip < 80 // control = bb9 < 2.0 // stamina = ip > 227 var starters = context.Starters.ToList(); var tempSAList = starters.FindAll(x => x.VarKo9 > 8.5); tempSAList.ForEach(x => context.StarterBuff.Add(new StarterBuff { StarterId = x.StarterId, FanId = x.FanId, BuffId = 1, })); Menu.PrintSystemMessage("\nStrikeout Artist (SA+) " + "qualified Starters inserted into StarterBuff table."); var tempGB = starters.FindAll(x => x.VarFip < 80); tempGB.ForEach(x => context.StarterBuff.Add(new StarterBuff { StarterId = x.StarterId, FanId = x.FanId, BuffId = 2 })); Menu.PrintSystemMessage("\nGroundball Machine (GB+)" + " qualified Starters inserted into StarterBuff table."); var tempCtrl = starters.FindAll(x => x.VarBb9 < 2.0); tempCtrl.ForEach(x => context.StarterBuff.Add(new StarterBuff { StarterId = x.StarterId, FanId = x.FanId, BuffId = 3 })); Menu.PrintSystemMessage("\nControl Pitcher (CN+)" + " qualified Starters inserted into StarterBuff table."); var tempStm = starters.FindAll(x => x.VarIps > 227); tempStm.ForEach(x => context.StarterBuff.Add(new StarterBuff { StarterId = x.StarterId, FanId = x.FanId, BuffId = 4 })); Menu.PrintSystemMessage("\nGreat Stamina (ST+)" + " qualified Starters inserted into StarterBuff table."); context.SaveChanges(); } }