Пример #1
0
        static void InsertIntoPitcher(List <PitcherFan> pitchers)
        {
            using (var context = new BBStats3Context())
            {
                pitchers.ForEach(x => context.Pitchers.Add(new Pitchers
                {
                    PitcherName = x.Name,
                    TeamName    = x.Team,
                    VarEra      = x.varERA,
                    VarIps      = x.varIPS,
                    VarKo9      = x.varKO9,
                    VarGbp      = x.varGBP,
                    VarBb9      = x.varBB9,
                    VarFb9      = x.varFBP
                }));

                //foreach (var x in pitchers)
                //{
                //    context.Pitchers.Add(new Pitchers
                //    {
                //        PitcherName = x.Name,
                //        TeamName = x.Team,
                //        VarEra = x.varERA,
                //        VarIps = x.varIPS,
                //        VarKo9 = x.varKO9,
                //        VarGbp = x.varGBP,
                //        VarBb9 = x.varBB9,
                //        VarFb9 = x.varFBP
                //    });
                //}

                context.SaveChanges();
            }
        }
Пример #2
0
        static void InsertIntoPitcherBuff(List <PitcherFan> pitchers)
        {
            using (var context = new BBStats3Context())
            {
                //   var pitchers = context.Pitchers.ToList();
                var buffs = context.Buffs.ToList();

                foreach (var p in pitchers)
                {
                    if (p.varKO9 > 8.0)
                    {
                        try
                        {
                            context.PitcherBuff.Add(new PitcherBuff
                            {
                                PitcherId = p.playerId,
                                BuffId    = 1
                            });


                            Console.WriteLine($"{p.playerId} {p.Name} has been added to the Database.");
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex);
                        }
                        //     context.PitcherBuff.InsertOn
                    }
                }

                Console.WriteLine($"\n{pitchers.Count} records added to database.");
                context.SaveChanges();
            }
        }
Пример #3
0
        static void InsertPitcherBuffTableGB()
        {
            try
            {
                using (var context = new BBStats3Context())
                {
                    var pitchers = context.Pitchers.ToList();

                    List <Pitchers> gmEligible = pitchers.FindAll(x => x.VarGbp >= 55.0);
                    gmEligible.ForEach(x => Console.WriteLine($"{x.PitcherName} " +
                                                              $"is eligible for Groundball Machine buff."));
                    gmEligible.ForEach(x => context.PitcherBuff.Add(new PitcherBuff
                    {
                        PitcherId = x.PitcherId,
                        BuffId    = 2
                    }));


                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Error inserting into pitcher buff table GB\n{ex}");
            }
        }
Пример #4
0
        static void InsertPitchersTable(List <Pitchers> pitchers)
        {
            using (var context = new BBStats3Context())
            {
                pitchers.ForEach(x => context.Pitchers.Add(new Pitchers
                {
                    PitcherName = x.PitcherName,
                    TeamName    = x.TeamName,
                    VarEra      = x.VarEra,
                    VarIps      = x.VarIps,
                    VarKo9      = x.VarKo9,
                    VarGbp      = x.VarGbp,
                    VarBb9      = x.VarBb9,
                    VarFb9      = x.VarFb9,
                    VarFanId    = x.VarFanId
                }));

                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine($"\n\n{context.Pitchers.Count()} added to Pitchers Table.\n\n");
                Console.ResetColor();
                context.SaveChanges();
            }
        }
Пример #5
0
        static void InsertPitcherBuffTableSA()
        {
            try
            {
                using (var context = new BBStats3Context())
                {
                    var pitchers = context.Pitchers.ToList();

                    List <Pitchers> saEligible = pitchers.FindAll(x => x.VarKo9 > 8);
                    saEligible.ForEach(x => Console.WriteLine($"{x.PitcherId} {x.VarKo9}"));
                    saEligible.ForEach(x => context.PitcherBuff.Add(new PitcherBuff
                    {
                        PitcherId = x.PitcherId,
                        BuffId    = 1
                    }));

                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Failed to load record.\n{ex}\n\n");
            }
        }