public ActionResult Create(Arbs_Football_MatchWinner footballarb)
        {
            if (ModelState.IsValid)
            {
                db.Arbs_Football_MatchWinner.Add(footballarb);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(footballarb));
        }
Example #2
0
        public void Run()
        {
            var bfExpiredFixtures = barbieEntity.BetFairFootballFixtures.Where(x => x.MatchDateTime < expiryDate);
            var ocExpiredFixtures = barbieEntity.OddsCheckerFootballFixtures.Where(x => x.MatchDateTime < expiryDate);

            var bfExpiredFixtureIDs = bfExpiredFixtures.Select(x => x.ID).ToList();
            var ocExpiredFixtureIDs = ocExpiredFixtures.Select(x => x.ID).ToList();

            var expiredFixtureMaps = barbieEntity.FootballFixturesMap
                                     .Where(x => bfExpiredFixtureIDs.Contains(x.BetFairFixtureID) || ocExpiredFixtureIDs.Contains(x.OddsCheckerFixtureID));
            var expiredFixtureMapIDs = expiredFixtureMaps.Select(x => x.ID).ToList();

            var bfExpiredOdds = barbieEntity.BetFairFootballOdds.Where(x => expiredFixtureMapIDs.Contains(x.ID));

            foreach (var record in bfExpiredOdds)
            {
                barbieEntity.BetFairFootballOdds.Remove(record);
            }

            barbieEntity.SaveChanges();

            var ocExpiredOdds = barbieEntity.OddsCheckerFootballOdds.Where(x => expiredFixtureMapIDs.Contains(x.ID));

            foreach (var record in ocExpiredOdds)
            {
                barbieEntity.OddsCheckerFootballOdds.Remove(record);
            }

            barbieEntity.SaveChanges();

            foreach (var record in expiredFixtureMaps)
            {
                barbieEntity.FootballFixturesMap.Remove(record);
            }

            barbieEntity.SaveChanges();

            foreach (var record in bfExpiredFixtures)
            {
                barbieEntity.BetFairFootballFixtures.Remove(record);
            }

            barbieEntity.SaveChanges();

            foreach (var record in ocExpiredFixtures)
            {
                barbieEntity.OddsCheckerFootballFixtures.Remove(record);
            }

            barbieEntity.SaveChanges();
        }
Example #3
0
        public void RunMapper()
        {
            // TODO: Externalise var to config file
            var maxLevenshteinValue = 15;

            for (var i = 0; i <= maxLevenshteinValue; i++)
            {
                unmappedBetFairFixtures     = GetAllUnmappedBetFairFixtures();
                unmappedOddsCheckerFixtures = GetAllUnmappedOddsCheckerFixtures();

                var mappedFixtures =
                    (from bf in unmappedBetFairFixtures
                     join oc in unmappedOddsCheckerFixtures
                     on bf.CompetitionID equals oc.CompetitionID
                     where bf.MatchDateTime == oc.MatchDateTime &&
                     levenshtein(bf.HomeTeam, oc.HomeTeam) <= i &&
                     levenshtein(bf.AwayTeam, oc.AwayTeam) <= i
                     select new FootballFixturesMap
                {
                    BetFairFixtureID = bf.ID,
                    OddsCheckerFixtureID = oc.ID,
                }).ToList();

                foreach (var fixture in mappedFixtures)
                {
                    barbieEntity.FootballFixturesMap.Add(fixture);
                }

                barbieEntity.SaveChanges();
            }
        }
Example #4
0
        // TODO: think about the arbs expiry process
        public void SetArbsExpiredForFinishedMatches()
        {
            // Get all arbs where matchdatetime has expired
            var expiredFixtures = (from arb in barbieEntity.Arbs_Football_MatchWinner
                                   join map in barbieEntity.FootballFixturesMap on arb.FixtureMapID equals map.ID
                                   join oc in barbieEntity.OddsCheckerFootballFixtures on map.OddsCheckerFixtureID equals oc.ID
                                   where oc.MatchDateTime < matchExpiryDateTime
                                   select arb).ToList();

            if (expiredFixtures.Count > 0)
            {
                foreach (var arb in expiredFixtures)
                {
                    arb.Expired = true;
                    arb.Updated = DateTime.Now;
                }

                barbieEntity.SaveChanges();
            }
        }
        public void ArchiveExpiredOdds()
        {
            var expiredOdds = barbieEntity.Arbs_Football_MatchWinner.Where(x => x.Expired == true);

            var oddsToArchive = new List <Arbs_Football_MatchWinner_Expired>();
            var oddsToDelete  = new List <Arbs_Football_MatchWinner>();

            foreach (var oddsRecord in expiredOdds)
            {
                var expiredOddsRecord = new Arbs_Football_MatchWinner_Expired
                {
                    OriginalID         = oddsRecord.ID,
                    MatchDateTime      = oddsRecord.MatchDateTime,
                    HomeTeam           = oddsRecord.HomeTeam,
                    AwayTeam           = oddsRecord.AwayTeam,
                    Bookie             = oddsRecord.Bookie,
                    BookieOdds         = oddsRecord.BookieOdds,
                    BetFairLayLevel    = oddsRecord.BetFairLayLevel,
                    BetFairOdds        = oddsRecord.BetFairOdds,
                    BetFairCash        = oddsRecord.BetFairCash,
                    Predication        = oddsRecord.Predication,
                    BetFairUpdated     = oddsRecord.BetFairUpdated,
                    OddsCheckerUpdated = oddsRecord.OddsCheckerUpdated,
                    Created            = oddsRecord.Created,
                    Updated            = oddsRecord.Updated,
                    ParentID           = oddsRecord.ParentID
                };

                oddsToDelete.Add(oddsRecord);
                oddsToArchive.Add(expiredOddsRecord);
            }

            foreach (var record in oddsToArchive)
            {
                barbieEntity.Arbs_Football_MatchWinner_Expired.Add(record);
            }

            foreach (var record in oddsToDelete)
            {
                barbieEntity.Arbs_Football_MatchWinner.Remove(record);
            }

            barbieEntity.SaveChanges();
        }