Пример #1
0
        public void IsMappedCorrectly()
        {
            var competition = new Models.Betfair.Response.Competition {
                Id = "compId", Name = "compName"
            };
            var homeTeam = new Models.Betfair.Response.Team {
                SelectionId = "home", Name = "homeTeamName", Metadata = new Metadata {
                    Id = "123456"
                }, Odds = 3.5m
            };
            var awayTeam = new Models.Betfair.Response.Team {
                SelectionId = "away", Name = "awayTeamName", Metadata = new Metadata {
                    Id = "987654"
                }, Odds = 12m
            };
            var source = new Market {
                Id = "id", Competition = competition, StartTime = DateTime.UtcNow, Teams = new[] { homeTeam, awayTeam }
            };

            var result = MatchOdds.From(source);

            Assert.Equal(source.Id, result.Id);
            Assert.Equal(competition.Id, result.CompetitionId);
            Assert.Equal(competition.Name, result.CompetitionName);
            Assert.Equal(source.StartTime, result.Date);
            Assert.Equal(homeTeam.Id, result.HomeTeamId);
            Assert.Equal(awayTeam.Id, result.AwayTeamId);
            Assert.Equal(homeTeam.Name, result.HomeTeamName);
            Assert.Equal(awayTeam.Name, result.AwayTeamName);
            Assert.Equal(homeTeam.Odds, result.HomeTeamOddsDecimal);
            Assert.Equal(awayTeam.Odds, result.AwayTeamOddsDecimal);
            Assert.Equal(OddsConverter.ToFractional(homeTeam.Odds), result.HomeTeamOdds);
            Assert.Equal(OddsConverter.ToFractional(awayTeam.Odds), result.AwayTeamOdds);
        }
Пример #2
0
        public void SavingOdds()
        {
            var database    = new OddsDatabase(this);
            var competition = new Models.Betfair.Response.Competition {
                Id = "compId", Name = "compName"
            };
            var homeTeam = new Models.Betfair.Response.Team {
                SelectionId = "home", Name = "homeTeamName", Metadata = new Metadata {
                    Id = "123456"
                }, Odds = 3.5m
            };
            var awayTeam = new Models.Betfair.Response.Team {
                SelectionId = "away", Name = "awayTeamName", Metadata = new Metadata {
                    Id = "987654"
                }, Odds = 12m
            };
            var source = new Market {
                Id = "id", Competition = competition, StartTime = DateTime.UtcNow, Teams = new[] { homeTeam, awayTeam }
            };
            var odds = MatchOdds.From(source);

            database.Save(odds);

            Assert.Equal(expectedSql, _sql);
            Assert.Same(odds, _odds);
        }
Пример #3
0
        public Result <bool> CreateOdd(int Identifier, int MatchIdendifier, string Specifier, decimal Odd)
        {
            var matchOdd = new MatchOdds();

            matchOdd.ID        = Identifier;
            matchOdd.MatchId   = MatchIdendifier;
            matchOdd.Specifier = Specifier;
            matchOdd.Odd       = Odd;


            dBcontext.Add(matchOdd);
            if (dBcontext.SaveChanges() >= 1)
            {
                resultbool.ResponseCode    = 0;
                resultbool.ResponseMessage = " DB Save : Successfully completed";
                resultbool.Data            = true;
                return(resultbool);
            }
            else
            {
                resultbool.ResponseCode    = 4;
                resultbool.ResponseMessage = "DB Save : Could not save in db";
                resultbool.Data            = false;
                return(resultbool);
            }
        }
        public async Task <IActionResult> GetMatchOdds(string matchID, string specifier)
        {
            try
            {
                bool valid = int.TryParse(matchID, out int id);

                List <string> specifiers = new List <string>()
                {
                    "1", "x", "2", "u", "o"
                };

                if (!valid || !specifiers.Contains(specifier.ToLower()))
                {
                    return(BadRequest(ModelState));
                }

                MatchOdds matchOdds = await _db.Matches.GetMatchOdds(id, specifier.ToUpper());

                if (matchOdds == null)
                {
                    return(StatusCode(204));
                }
                else
                {
                    return(Ok(matchOdds));
                }
            }
            catch (Exception)
            {
                // log exception
                return(StatusCode(500));
            }
        }
Пример #5
0
        public async Task <IActionResult> Post([FromBody] MatchOdds matchOdds)
        {
            try
            {
                await matchOddsRepository.CreateAsync(matchOdds);

                await matchOddsRepository.SaveAsync();
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
            return(Ok("Match odd created succesfully"));
        }
Пример #6
0
        public async Task <bool> CreateMatchOdds(MatchOdds odds)
        {
            if (await GetMatchOdds(odds.MatchID, odds.Specifier) != null)
            {
                await UpdateMatchOdds(odds);
            }
            else
            {
                await _db.MatchOdds.AddAsync(odds);

                await _db.SaveChangesAsync();
            }

            return(true);
        }
Пример #7
0
        public async Task <IActionResult> DeleteOdd(int id)
        {
            try
            {
                MatchOdds matchOdds = await matchOddsRepository.GetByIdAsync(id);

                await matchOddsRepository.DeleteAsync(matchOdds);

                await matchOddsRepository.SaveAsync();

                return(Ok("Successfully deleted"));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Пример #8
0
        public async Task <bool> UpdateMatchOdds(MatchOdds odds)
        {
            MatchOdds oldOdds = await _db.MatchOdds.Where(x => x.MatchID == odds.MatchID && x.Specifier == odds.Specifier).FirstOrDefaultAsync();

            if (oldOdds == null)
            {
                await CreateMatchOdds(odds);
            }
            else
            {
                oldOdds.Odd = odds.Odd;
                _db.Entry(oldOdds).CurrentValues.SetValues(oldOdds);
            }

            await _db.SaveChangesAsync();

            return(true);
        }
Пример #9
0
        public async Task <IActionResult> UpdateMatchOdds(int id, [FromBody] MatchOdds matchOdds)
        {
            try
            {
                MatchOdds dbEntity = await matchOddsRepository.GetByIdAsync(id);

                dbEntity.MatchId   = matchOdds.MatchId;
                dbEntity.Odd       = matchOdds.Odd;
                dbEntity.Specifier = matchOdds.Specifier;

                await matchOddsRepository.UpdateAsync(dbEntity);

                await matchOddsRepository.SaveAsync();

                return(Ok("Match odds updated successfully"));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Пример #10
0
        public IActionResult UpdateOdd(MatchOdds matchOdds)
        {
            var temp = service.UpdateOdd(matchOdds.ID, matchOdds.MatchId, matchOdds.Specifier, matchOdds.Odd);

            return(Ok(temp));
        }
Пример #11
0
        public async Task <IActionResult> GetMatchOdds(int id)
        {
            MatchOdds matchOdds = await matchOddsRepository.GetByIdAsync(id);

            return(Ok(matchOdds));
        }
Пример #12
0
 private static void Main(string[] args)
 {
     var odds = MatchOdds.LoadMatchOddsList();
 }
Пример #13
0
 public void DeleteMatchOdd(MatchOdds matchOdds)
 {
     _context.MatchOdds.Remove(matchOdds);
 }
Пример #14
0
 public void UpdateMatchOddsForMatch(int matchId, MatchOdds matchOdds)
 {
 }
Пример #15
0
        public void AddMatchOddsForMatch(int matchId, MatchOdds matchOdds)
        {
            var match = GetMatch(matchId, false);

            match.MatchOdds.Add(matchOdds);
        }