Example #1
0
        public void Run()
        {
            using (VilkaEntities context = new VilkaEntities())
            {
                IQueryable <EventSiteData> liveEventSiteDatas = context.EventSiteDatas.Where((d) => d.Event.PrematchEnd <= DateTime.Now);
                Console.WriteLine(liveEventSiteDatas.Count() + "Event Datas found.");
                context.EventSiteDatas.RemoveRange(liveEventSiteDatas);

                IQueryable <Outcome> liveOutcomes = context.Outcomes.Where((d) => d.BetOffer.Event.PrematchEnd <= DateTime.Now);
                Console.WriteLine(liveOutcomes.Count() + "Outcomes found.");
                context.Outcomes.RemoveRange(liveOutcomes);

                IQueryable <BetOffer> liveBetOffers = context.BetOffers.Where((d) => d.Event.PrematchEnd <= DateTime.Now);
                Console.WriteLine(liveBetOffers.Count() + "Bet Offers found.");
                context.BetOffers.RemoveRange(liveBetOffers);

                IQueryable <Event> liveEvents = context.Events.Where((d) => d.PrematchEnd <= DateTime.Now);
                Console.WriteLine(liveEvents.Count() + "Events found.");
                context.Events.RemoveRange(liveEvents);

                Console.WriteLine("Removing live Events...");
                Console.WriteLine(context.SaveChanges() + " rows affected.");
                Console.WriteLine();
            }
        }
Example #2
0
 private void AnswerLeagueCompareRequest(CompareLeague l, bool answer)
 {
     using (VilkaEntities context = new VilkaEntities())
     {
         if (answer == true)
         {
             League league = context.Leagues.Where((i) => i.Name == l.First || i.Name == l.Second).FirstOrDefault();
             if (league == null)
             {
                 League newLeague = new League();
                 newLeague.Name     = l.First;
                 newLeague.SportID  = l.SportID;
                 newLeague.RegionID = l.RegionID;
                 league             = context.Leagues.Add(newLeague);
                 context.SaveChanges();
             }
             Tuple <string, Region, Sport> keyFirst  = new Tuple <string, Region, Sport>(l.First, l.Region, l.Sport);
             Tuple <string, Region, Sport> keySecond = new Tuple <string, Region, Sport>(l.Second, l.Region, l.Sport);
             if (!Dicts.LeagueDict.ContainsKey(keyFirst))
             {
                 Dicts.LeagueDict.Add(keyFirst, league);
             }
             if (!Dicts.LeagueDict.ContainsKey(keySecond))
             {
                 Dicts.LeagueDict.Add(keySecond, league);
             }
         }
         context.CompareLeagues.Remove(context.CompareLeagues.Where((i) => i.ID == l.ID).FirstOrDefault());
         context.SaveChanges();
     }
 }
Example #3
0
 public static BetTarget DBCopy(this BetTarget betTarget, VilkaEntities context)
 {
     if (betTarget == null)
     {
         return(null);
     }
     return(context.BetTargets.Where((b) => b.ID == betTarget.ID).FirstOrDefault());
 }
Example #4
0
 public static Sport DBCopy(this Sport sport, VilkaEntities context)
 {
     if (sport == null)
     {
         return(null);
     }
     return(context.Sports.Where((s) => s.ID == sport.ID).FirstOrDefault());
 }
Example #5
0
        public static OutcomeType DBCopy(this OutcomeType ot, VilkaEntities context)
        {
            if (ot == null)
            {
                return(null);
            }

            return(context.OutcomeTypes.Where((o) => o.ID == ot.ID).FirstOrDefault());
        }
Example #6
0
        public static Event DBCopy(this Event ev, VilkaEntities context)
        {
            if (ev == null)
            {
                return(null);
            }

            return(context.Events.Where((e) => e.ID == ev.ID).FirstOrDefault());
        }
Example #7
0
        public static BetType DBCopy(this BetType betType, VilkaEntities context)
        {
            if (betType == null)
            {
                return(null);
            }

            return(context.BetTypes.Where((b) => b.ID == betType.ID).FirstOrDefault());
        }
Example #8
0
 public void ComperatorGetNextLeague(Action <string, string, string, string, Action <bool> > callback)
 {
     using (VilkaEntities context = new VilkaEntities())
     {
         if (context.CompareLeagues.Count() == 0)
         {
             callback("Nothing Found", "Nothing Found", "Nothing Found", "Nothing Found", (a) => { });
         }
         CompareLeague l = context.CompareLeagues.First();
         callback(l.First, l.Second, l.Region.Name, l.Sport.Name, (a) => AnswerLeagueCompareRequest(l, a));
     }
 }
Example #9
0
 public void EnsureBetTargets()
 {
     if (ID == 0)
     {
         throw new Exception("Better ID should be initialized before BetTargets.");
     }
     using (VilkaEntities context = new VilkaEntities())
     {
         List <BetTargetMapping> mappings = context.BetTargetMappings.Where((mapping) => mapping.SiteID == ID).ToList();
         foreach (BetTargetMapping mapping in mappings)
         {
             BetTargetMappings.Add(mapping.Name, mapping.BetTarget);
         }
     }
 }
Example #10
0
 public void EnsureOutcomeTypes()
 {
     if (ID == 0)
     {
         throw new Exception("Better ID should be initialized before OutcomeTypes.");
     }
     using (VilkaEntities context = new VilkaEntities())
     {
         List <OutcomeTypeMapping> mappings = context.OutcomeTypeMappings.Where((mapping) => mapping.SiteID == ID).ToList();
         foreach (OutcomeTypeMapping mapping in mappings)
         {
             OutcomeTypeMappings.Add(mapping.Name, mapping.OutcomeType);
         }
     }
 }
Example #11
0
 public void EnsureSports()
 {
     if (ID == 0)
     {
         throw new Exception("ID should be initialized before SportMappings.");
     }
     using (VilkaEntities context = new VilkaEntities())
     {
         List <SportMapping> mappings = context.SportMappings.Where((mapping) => mapping.SiteID == ID).ToList();
         foreach (SportMapping mapping in mappings)
         {
             SportMappings.Add(mapping.Name, mapping.Sport);
         }
     }
 }
Example #12
0
 public void EnsureID()
 {
     using (VilkaEntities context = new VilkaEntities())
     {
         Site better = context.Sites.Where((site) => site.Name == Name).FirstOrDefault();
         if (better == null)
         {
             better      = new Site();
             better.Name = Name;
             context.Sites.Add(better);
             context.SaveChanges();
         }
         ID = better.ID;
     }
 }
Example #13
0
 public static Event FindEvent(Event ev)
 {
     using (VilkaEntities context = new VilkaEntities())
     {
         foreach (Event item in context.Events)
         {
             if (!item.IsLive())
             {
                 if (Comparator.CompareEvents(item, ev))
                 {
                     return(item);
                 }
             }
         }
         return(null);
     }
 }