public ActionResult AddExoticPayout(int id, BetTypes bet) { this.ViewData.Model = leagueRaceRepository.Get(id); this.ViewData["BetType"] = bet; return View(); }
public List <dynamic> GetBets(int id, int page, int size, BetTypes type) { if (!Users.ContainsKey(id)) { throw new NotFoundException("User not found"); } return(Users[id].Bets .Select(kvp => new { Id = kvp.Id, Stake = kvp.Stake, Win = kvp.Win, Timestamp = kvp.Timestamp }) .OrderBy(s => s.Id) .Where(kvp => { switch (type) { case BetTypes.All: return kvp.Win >= 0; case BetTypes.Lost: return kvp.Win == 0; case BetTypes.Winning: return kvp.Win > 0; default: return true; } }) .Skip((page - 1) * size) .Take(size) .ToList <dynamic>()); }
public static string GetGraphUrl(IList<ReportLeagueRaceBet> curReport, BetTypes betType, int imagePad) { float multiplier = 0.0f; StringBuilder builder = new StringBuilder(@"http://chart.apis.google.com/chart?chxt=y"); //builder.Append(String.Format("&chtt={0}%20Picks", betType.ToString())); builder.Append(@"&cht=bhs&chxt=y"); builder.Append("&chxl=0:"); for(int i = curReport.Count - 1; i > -1; i--) { builder.Append(String.Format(@"|{0}", curReport[i].RaceDetail.Horse.Name.Replace(" ", "+"))); } builder.Append(String.Format("&chs=300x{0}", imagePad * curReport.Count)); builder.Append(@"&chco=034af3"); builder.Append(@"&chd=t:"); for(int i=0; i < curReport.Count; i++) { if (i == 0 && curReport[i].UserBetCount != 0) { multiplier = 100 / curReport[i].UserBetCount; } if(i > 0) { builder.Append(","); } builder.Append((curReport[i].UserBetCount * multiplier).ToString()); } return builder.ToString(); }
public RDeepBetTypeWiningNumbersList(int factor, BetTypes bet, List <int[]> betWinningNumbersList) { betWiningNumbersList = betWinningNumbersList; Factor = factor; betType = bet; ID = ++RDeepWiningNumbersList.Total; }
public static List <int[]> GetBetPositions(BetTypes bet) { List <int[]> betPositions = new List <int[]>(); foreach (RDeepBetPosition p in betPositionList) { if (p.betType == bet) { betPositions.Add(p.betPositions); } } return(betPositions); }
private static RDeepBetTypeWiningNumbersList GetWiningNumbersListByBetType(BetTypes bet) { RDeepBetTypeWiningNumbersList result = null; foreach (RDeepBetTypeWiningNumbersList betTypeWinnningNumbersList in RDeepWiningNumbersList.betTypeWinningNumbersLists) { if (betTypeWinnningNumbersList.betType == bet) { result = betTypeWinnningNumbersList; } } return(result); }
public IList<ReportLeagueRaceBet> GetListByType(BetTypes betType) { switch(betType) { case BetTypes.Win: return Win; case BetTypes.Place: return Place; case BetTypes.Show: return Show; default: return null; } }
public virtual void AddUserPick(LeagueRace leagueRace, RaceDetail raceDetail, BetTypes betType) { var userPick = GetPicksForARace(leagueRace).Where(x => x.BetType == betType).FirstOrDefault(); if (userPick != null && userPick.RaceDetail != raceDetail) { this.UserRaceDetails.Remove(userPick); } else if(userPick != null && userPick.RaceDetail == raceDetail) { return; } createAndAddUserRace(betType, raceDetail); }
internal static int BetPayOutFactorByBet(BetTypes bet) { int result = 0; foreach (RDeepBetTypeWiningNumbersList betTypeWinnningNumberList in betTypeWinningNumbersLists) { if (betTypeWinnningNumberList.betType == bet) { result = betTypeWinnningNumberList.Factor; } } return(result); }
public int Add(BetTypes entity) { int rowAffected = 0; using (var connection = DbService.sqlConnection()) { if (connection.State == ConnectionState.Closed) { connection.Open(); } DynamicParameters parameters = new DynamicParameters(); parameters.Add("@BetType", entity.Bettype); rowAffected = connection.Execute("AddBettype", parameters, commandType: CommandType.StoredProcedure); } return(rowAffected); }
public ActionResult AddExoticPayout(int id, BetTypes bet, FormCollection collection) { LeagueRace leagueRace = this.leagueRaceRepository.Get(id); string amountTemp = collection["Amount"]; float amount = float.MinValue; if(float.TryParse(amountTemp, out amount)) { RaceExoticPayout payout = new RaceExoticPayout() { Amount = amount, BetType = bet, LeagueRace = leagueRace }; leagueRace.RaceExoticPayouts.Add(payout); leagueRaceRepository.SaveOrUpdate(leagueRace); } return RedirectToAction("ViewLeagueRace", new { id = id }); }
public Bet getBet(BetTypes type) { Bet toReturn = null; switch (type) { case BetTypes.POLITIC: toReturn = new Politic(); break; case BetTypes.FOOTBALL: toReturn = new Football(); break; case BetTypes.FORMULA1: toReturn = new Formula1(); break; default: throw new ArgumentOutOfRangeException("Wrong bet type:" + type); } return(toReturn); }
public static UserRaceDetail GetUserSelection(IList<UserRaceDetail> userPicks, BetTypes betType, System.Guid userId) { return (from up in userPicks where up.BetType == betType && up.UserLeague.User.Id == userId select up).FirstOrDefault(); }
public static RaceDetailPayout GetPayout(BetTypes payoutType, LeagueRace leagueRace) { var payout = leagueRace.GetPayout(payoutType); if (payout == null) payout = new RaceDetailPayout() { RaceDetail = new RaceDetail() { Horse = new Horse() } }; return payout; }
private void CreatePickText(LeagueRace leagueRace, StringBuilder output, BetTypes betType) { RaceDetail rd = this.GetUserPickByType(leagueRace, betType).RaceDetail; output.AppendLine(String.Format("{0}: {1}-{2}", betType.ToString(), rd.PostPosition, rd.Horse.Name)); }
private static RDeepBetTypeWiningNumbersList LoadBetTypeWiningNumbersList(BetTypes bet) { List <int[]> BetTypeWiningNumbersList = new List <int[]>(); int Factor = 0; if (bet == BetTypes.StraightUp) { BetTypeWiningNumbersList = new List <int[]> { new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37 } }; Factor = 35; } else if (bet == BetTypes.Row || bet == BetTypes.Split) { BetTypeWiningNumbersList = RDeepBetPositions.GetBetPositions(bet); Factor = 17; } else if (bet == BetTypes.Street) { BetTypeWiningNumbersList = new List <int[]> { new int[] { 0, 1, 2, }, //0, 1, 2 new int[] { 37, 2, 3, }, //00, 2, 3 new int[] { 1, 2, 3, }, new int[] { 4, 5, 6, }, new int[] { 7, 8, 9 }, new int[] { 10, 11, 12 }, new int[] { 13, 14, 15 }, new int[] { 16, 17, 18 }, new int[] { 19, 20, 21 }, new int[] { 22, 23, 24 }, new int[] { 28, 29, 30 }, new int[] { 31, 32, 33 }, new int[] { 34, 35, 36 } }; Factor = 11; } else if (bet == BetTypes.Corner) { BetTypeWiningNumbersList = RDeepBetPositions.GetBetPositions(bet); Factor = 8; } else if (bet == BetTypes.TopLineOrBasket) { BetTypeWiningNumbersList = new List <int[]> { new int[] { 0, 37, 2, 3 }, //"0, 00, 1, 2, 3" }; Factor = 6; } else if (bet == BetTypes.SixLine) { BetTypeWiningNumbersList = new List <int[]> { new int[] { 0, 37, 1, 2, 3 }, //0, 00, 1, 2, 3 new int[] { 1, 2, 3, 4, 5, 6 }, new int[] { 4, 5, 6, 7, 8, 9 }, new int[] { 7, 8, 9, 10, 11, 12 }, new int[] { 10, 11, 12, 13, 14, 15 }, new int[] { 13, 14, 15, 16, 17, 18 }, new int[] { 16, 17, 18, 19, 20, 21 }, new int[] { 19, 20, 21, 22, 23, 24 }, new int[] { 22, 23, 24, 25, 26, 27 }, new int[] { 25, 26, 27, 28, 29, 30 }, new int[] { 28, 29, 30, 31, 32, 33 }, new int[] { 31, 32, 33, 34, 35, 36 } }; Factor = 6; } else if (bet == BetTypes.FirstDozen) { BetTypeWiningNumbersList = new List <int[]> { new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 } // 1 to 12 }; Factor = 2; } else if (bet == BetTypes.SecondDozen) { BetTypeWiningNumbersList = new List <int[]> { new int[] { 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24 } // 13 to 24 }; Factor = 2; } else if (bet == BetTypes.ThirdDozen) { BetTypeWiningNumbersList = new List <int[]> { new int[] { 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36 } // 25 to 36 }; Factor = 2; } else if (bet == BetTypes.FirstColumn) { BetTypeWiningNumbersList = new List <int[]> { new int[] { 1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34 } // }; Factor = 2; } else if (bet == BetTypes.SecondColumn) { BetTypeWiningNumbersList = new List <int[]> { new int[] { 2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35 } // }; Factor = 2; } else if (bet == BetTypes.ThirdColumn) { BetTypeWiningNumbersList = new List <int[]> { new int[] { 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36 } // }; Factor = 2; } else if (bet == BetTypes.Odd) { BetTypeWiningNumbersList = new List <int[]> { new int[] { 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35 } //Odd numbers 1, 3, 5 .... 35 }; Factor = 1; } else if (bet == BetTypes.Even) { BetTypeWiningNumbersList = new List <int[]> { new int[] { 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36 } //Even numbers 2, 4, 6 .... 36 }; Factor = 1; } else if (bet == BetTypes.Red) { BetTypeWiningNumbersList = new List <int[]> { new int[] { 1, 3, 5, 7, 9, 12, 14, 16, 18, 19, 21, 23, 25, 27, 30, 32, 34, 36 } }; Factor = 1; } else if (bet == BetTypes.Black) { BetTypeWiningNumbersList = new List <int[]> { new int[] { 2, 4, 6, 8, 10, 11, 13, 15, 17, 20, 22, 24, 26, 28, 29, 31, 33, 35 } }; Factor = 1; } else if (bet == BetTypes.OneToEighteen) { BetTypeWiningNumbersList = new List <int[]> { new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18 } // 1 to 18 }; Factor = 1; } else if (bet == BetTypes.NinteenToThirtyEight) { BetTypeWiningNumbersList = new List <int[]> { new int[] { 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36 } // 19 to 36 }; Factor = 1; } return(new RDeepBetTypeWiningNumbersList(Factor, bet, BetTypeWiningNumbersList)); }
public ActionResult AddPayout(int id, BetTypes bet, FormCollection collection) { RaceDetailPayout payout = initializePayout(id, bet); #region Validation string raceDetailIdTemp = collection["RaceDetailId"]; int raceDetailId; if (!Int32.TryParse(raceDetailIdTemp, out raceDetailId)) { ModelState.AddModelError("RaceDetailId", "The horse must be selected"); return View(); } string winAmountTemp = collection["WinAmount"]; float winAmount = float.MinValue; if (isWinEnabled(payout) && !float.TryParse(winAmountTemp, out winAmount)) { ModelState.AddModelError("WinAmount", "The win amount can not be blank"); return View(); } string placeAmountTemp = collection["PlaceAmount"]; float placeAmount = float.MinValue; if (isPlaceEnabled(payout) && !float.TryParse(placeAmountTemp, out placeAmount)) { ModelState.AddModelError("PlaceAmount", "The place amount can not be blank"); return View(); } string showAmountTemp = collection["ShowAmount"]; float showAmount = float.MinValue; if (!float.TryParse(showAmountTemp, out showAmount)) { ModelState.AddModelError("ShowAmount", "The show amount can not be blank"); return View(); } #endregion RaceDetail raceDetail = raceDetailRepository.Get(raceDetailId); payout.RaceDetail = raceDetail; payout.WinAmount = payout.BetType == BetTypes.Win ? (float?)winAmount : null; payout.PlaceAmount = payout.BetType != BetTypes.Show ? (float?)placeAmount : null; payout.ShowAmount = showAmount; raceDetail.RaceDetailPayout.Add(payout); this.raceDetailRepository.SaveOrUpdate(raceDetail); return RedirectToAction("ViewLeagueRace", new { id = id }); }
public RDeepBetPosition(BetTypes bet, int[] positions) { betPositions = positions; betType = bet; ID = ++RDeepBetPositions.Total; }
private static void LoadRDeepBetPositions(BetTypes BetType, int position = -1) { List <int[]> betPositions; betPositions = new List <int[]>(); switch (BetType) { case BetTypes.StraightUp: betPositions.Add(new int[] { position }); break; case BetTypes.Row: betPositions = new List <int[]> { new int[] { 0, 37 }, new int[] { 0, 1 }, new int[] { 0, 2 }, new int[] { 37, 2 }, new int[] { 37, 3 } }; break; case BetTypes.Split: betPositions = new List <int[]> { new int[] { 1, 2 }, new int[] { 2, 3 }, new int[] { 1, 4 }, new int[] { 2, 5 }, new int[] { 3, 6 }, new int[] { 4, 5 }, new int[] { 5, 6 }, new int[] { 4, 7 }, new int[] { 5, 8 }, new int[] { 6, 9 }, new int[] { 7, 8 }, new int[] { 8, 9 }, new int[] { 7, 10 }, new int[] { 8, 11 }, new int[] { 9, 12 }, new int[] { 10, 11 }, new int[] { 11, 12 }, new int[] { 10, 13 }, new int[] { 11, 14 }, new int[] { 12, 15 }, new int[] { 13, 14 }, new int[] { 14, 15 }, new int[] { 13, 16 }, new int[] { 14, 17 }, new int[] { 15, 18 }, new int[] { 16, 17 }, new int[] { 17, 18 }, new int[] { 16, 19 }, new int[] { 17, 20 }, new int[] { 18, 21 }, new int[] { 19, 20 }, new int[] { 20, 21 }, new int[] { 19, 22 }, new int[] { 20, 23 }, new int[] { 21, 24 }, new int[] { 22, 23 }, new int[] { 23, 24 }, new int[] { 22, 25 }, new int[] { 23, 26 }, new int[] { 24, 27 }, new int[] { 25, 26 }, new int[] { 26, 27 }, new int[] { 25, 28 }, new int[] { 26, 29 }, new int[] { 27, 30 }, new int[] { 28, 29 }, new int[] { 29, 30 }, new int[] { 28, 31 }, new int[] { 29, 32 }, new int[] { 30, 33 }, new int[] { 31, 32 }, new int[] { 32, 33 }, new int[] { 31, 34 }, new int[] { 32, 35 }, new int[] { 33, 36 }, new int[] { 34, 35 }, new int[] { 35, 36 } }; break; case BetTypes.Street: betPositions.Add(new int[] { 1, RDeepPosition.FirstDozen.ID }); betPositions.Add(new int[] { 4, RDeepPosition.FirstDozen.ID }); betPositions.Add(new int[] { 7, RDeepPosition.FirstDozen.ID }); betPositions.Add(new int[] { 10, RDeepPosition.FirstDozen.ID }); betPositions.Add(new int[] { 13, RDeepPosition.SecondDozen.ID }); betPositions.Add(new int[] { 16, RDeepPosition.SecondDozen.ID }); betPositions.Add(new int[] { 19, RDeepPosition.SecondDozen.ID }); betPositions.Add(new int[] { 22, RDeepPosition.SecondDozen.ID }); betPositions.Add(new int[] { 25, RDeepPosition.ThirdDozen.ID }); betPositions.Add(new int[] { 28, RDeepPosition.ThirdDozen.ID }); betPositions.Add(new int[] { 31, RDeepPosition.ThirdDozen.ID }); betPositions.Add(new int[] { 34, RDeepPosition.ThirdDozen.ID }); break; case BetTypes.Corner: betPositions = new List <int[]> { new int[] { 1, 2, 4, 5 }, new int[] { 2, 3, 5, 6 }, new int[] { 4, 5, 7, 8 }, new int[] { 5, 6, 8, 9 }, new int[] { 7, 8, 10, 11 }, new int[] { 8, 9, 11, 12 }, new int[] { 10, 11, 13, 14 }, new int[] { 11, 12, 14, 15 }, new int[] { 13, 14, 16, 17 }, new int[] { 14, 15, 17, 18 }, new int[] { 16, 17, 19, 20 }, new int[] { 17, 18, 20, 21 }, new int[] { 19, 20, 22, 23 }, new int[] { 20, 21, 23, 24 }, new int[] { 22, 23, 25, 26 }, new int[] { 23, 24, 26, 27 }, new int[] { 25, 26, 28, 29 }, new int[] { 26, 27, 29, 30 }, new int[] { 28, 29, 31, 32 }, new int[] { 29, 30, 32, 33 }, new int[] { 31, 32, 34, 35 }, new int[] { 32, 33, 35, 36 } }; break; case BetTypes.TopLineOrBasket: betPositions.Add(new int[] { 0, 1, RDeepPosition.FirstDozen.ID }); break; case BetTypes.SixLine: betPositions.Add(new int[] { 1, 4, RDeepPosition.FirstDozen.ID }); betPositions.Add(new int[] { 4, 7, RDeepPosition.FirstDozen.ID }); betPositions.Add(new int[] { 7, 10, RDeepPosition.FirstDozen.ID }); betPositions.Add(new int[] { 10, 13, RDeepPosition.FirstDozen.ID, RDeepPosition.SecondDozen.ID }); betPositions.Add(new int[] { 13, 16, RDeepPosition.SecondDozen.ID }); betPositions.Add(new int[] { 16, 19, RDeepPosition.SecondDozen.ID }); betPositions.Add(new int[] { 19, 22, RDeepPosition.SecondDozen.ID }); betPositions.Add(new int[] { 22, 25, RDeepPosition.SecondDozen.ID, RDeepPosition.ThirdDozen.ID }); betPositions.Add(new int[] { 25, 28, RDeepPosition.ThirdDozen.ID }); betPositions.Add(new int[] { 28, 31, RDeepPosition.ThirdDozen.ID }); betPositions.Add(new int[] { 31, 34, RDeepPosition.ThirdDozen.ID }); break; case BetTypes.FirstDozen: betPositions.Add(new int[] { RDeepPosition.FirstDozen.ID }); break; case BetTypes.SecondDozen: betPositions.Add(new int[] { RDeepPosition.SecondDozen.ID }); break; case BetTypes.ThirdDozen: betPositions.Add(new int[] { RDeepPosition.ThirdDozen.ID }); break; case BetTypes.FirstColumn: betPositions.Add(new int[] { RDeepPosition.FirstColumn.ID }); break; case BetTypes.SecondColumn: betPositions.Add(new int[] { RDeepPosition.SecondColumn.ID }); break; case BetTypes.ThirdColumn: betPositions.Add(new int[] { RDeepPosition.ThirdColumn.ID }); break; case BetTypes.Odd: betPositions.Add(new int[] { RDeepPosition.Odd.ID }); break; case BetTypes.Even: betPositions.Add(new int[] { RDeepPosition.Even.ID }); break; case BetTypes.Black: betPositions.Add(new int[] { RDeepPosition.Black.ID }); break; case BetTypes.Red: betPositions.Add(new int[] { RDeepPosition.Red.ID }); break; case BetTypes.OneToEighteen: betPositions.Add(new int[] { RDeepPosition.OneToEighteen.ID }); break; case BetTypes.NinteenToThirtyEight: betPositions.Add(new int[] { RDeepPosition.NineteenToThirtySix.ID }); break; } foreach (int[] betPosition in betPositions) { betPositionList.Add(new RDeepBetPosition(BetType, betPosition)); } }
public virtual UserRaceDetail GetUserPickByType(LeagueRace leagueRace, BetTypes betType) { return this.GetPicksForARace(leagueRace).Where(x => x.BetType == betType).FirstOrDefault(); }
public static IList<SelectListItem> PopulateHorseDropDown(IList<RaceDetail> raceDetails, IList<UserRaceDetail> userPicks, BetTypes betType, System.Guid userId) { UserRaceDetail userRaceDetail = GetUserSelection(userPicks, betType, userId); return PopulateHorseDropDown(raceDetails, (RaceDetail raceDetail) => { if (userRaceDetail != null && userRaceDetail.RaceDetail == raceDetail) { return true; } else { return false; } }); }
public virtual RaceDetailPayout GetPayout(BetTypes payoutType) { return this.RaceDetailPayouts.Where(x => x.BetType == payoutType).FirstOrDefault(); }
private RaceDetailPayout initializePayout(int id, BetTypes bet) { LeagueRace leagueRace = this.UserLeague.League.GetLeagueRace(id); RaceDetailPayout payout = new RaceDetailPayout() { BetType = bet, LeagueRace = leagueRace }; this.ViewData.Model = payout; this.ViewData["LeagueRace"] = leagueRace; this.ViewData["IsWinEnabled"] = isWinEnabled(payout); this.ViewData["IsPlaceEnabled"] = isPlaceEnabled(payout); return payout; }
public int Put([FromBody] BetTypes betTypes) { return(_betType.Update(betTypes)); }
public int Post([FromBody] BetTypes betTypes) { return(_betType.Add(betTypes)); }
private void createAndAddUserRace(BetTypes betType, RaceDetail raceDetail) { UserRaceDetail urd = new UserRaceDetail(); urd.BetType = betType; urd.RaceDetail = raceDetail; urd.UserLeague = this; urd.UpdateDate = System.DateTime.Now; this.UserRaceDetails.Add(urd); }
public Task <HttpResponseMessage> GetBets(int id, int page, int size, BetTypes type) { var bets = repository.GetBets(id, page, size, type); return(Task.FromResult(Request.CreateResponse(HttpStatusCode.Found, bets))); }
public ActionResult AddPayout(int id, BetTypes bet) { this.initializePayout(id, bet); return View(); }