public async Task <ActionResult> DeleteConfirmed(int id) { var match = await BetDatabase.Matches.FindAsync(id); BetDatabase.Matches.Remove(match); await BetDatabase.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task <ActionResult> Create([Bind(Include = "MatchNo,setno,champ,HomeTeamId,AwayTeamId,stime,status,date_reg,HomeScore,AwayScore,Hthomescore,HtAwayScore,resultstatus")] Match match) { if (!ModelState.IsValid) { return(View(match)); } BetDatabase.Matches.Add(match); await BetDatabase.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task <ActionResult> Edit([Bind(Include = "shiftid,startdate,startcash,endcash,assignedto,AssigneBetDatabasey,TerminalId")] Shift shift) { if (ModelState.IsValid) { BetDatabase.Entry(shift).State = EntityState.Modified; await BetDatabase.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.TerminalId = new SelectList(BetDatabase.Terminals, "Terminalid", "TerminalName", shift.TerminalId); return(View(shift)); }
public async Task <ActionResult> Edit([Bind(Include = "MatchNo,setno,champ,HomeTeamId,AwayTeamId,stime,status,date_reg,HomeScore,AwayScore,Hthomescore,HtAwayScore,resultstatus")] Match match) { if (ModelState.IsValid) { BetDatabase.Entry(match).State = EntityState.Modified; await BetDatabase.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.HomeTeamId = new SelectList(BetDatabase.Teams, "TeamId", "TeamName", match.HomeTeamId); ViewBag.AwayTeamId = new SelectList(BetDatabase.Teams, "TeamId", "TeamName", match.AwayTeamId); return(View(match)); }
public async Task <ActionResult> Edit([Bind(Include = "BetServiceMatchNo,SetNo,League,StartTime,GameStatus,AwayTeamId,HomeTeamId,RegistrationDate,HomeScore,AwayScore,HalfTimeHomeScore,HalfTimeAwayScore,ResultStatus")] Match game) { if (ModelState.IsValid) { BetDatabase.Entry(game).State = EntityState.Modified; await BetDatabase.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.AwayTeamId = new SelectList(BetDatabase.Teams, "TeamId", "TeamName", game.AwayTeamId); ViewBag.HomeTeamId = new SelectList(BetDatabase.Teams, "TeamId", "TeamName", game.HomeTeamId); return(View(game)); }
public async Task <ActionResult> Create([Bind(Include = "MatchNo,SetNo,Champ,StartTime,GameStatus,AwayTeamId,HomeTeamId,RegistrationDate,HomeScore,AwayScore,HalfTimeHomeScore,HalfTimeAwayScore,ResultStatus")] Match game) { if (ModelState.IsValid) { BetDatabase.Matches.Add(game); await BetDatabase.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.AwayTeamId = new SelectList(BetDatabase.Teams, "TeamId", "TeamName", game.AwayTeamId); ViewBag.HomeTeamId = new SelectList(BetDatabase.Teams, "TeamId", "TeamName", game.HomeTeamId); return(View(game)); }
public async Task <ActionResult> Create([Bind(Include = "BetServiceMatchNo,League,StartTime,GameStatus,AwayTeamId,HomeTeamId,RegistrationDate,HomeScore,AwayScore,HalfTimeHomeScore,HalfTimeAwayScore,ResultStatus")] Match match) { if (ModelState.IsValid) { BetDatabase.Matches.Add(match); await BetDatabase.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.AwayTeamId = new SelectList(BetDatabase.Teams, "TeamId", "TeamName", match.AwayTeamId); ViewBag.HomeTeamId = new SelectList(BetDatabase.Teams, "TeamId", "TeamName", match.HomeTeamId); ViewBag.BetServiceMatchNo = new SelectList(BetDatabase.ShortMatchCodes, "MatchNo", "MatchNo", match.BetServiceMatchNo); return(View(match)); }
public async Task <JsonResult> ReceiveReceipt(Receipt1 receipts) { var bcg = new BarCodeGenerator(); var account = await BetDatabase.Accounts.SingleOrDefaultAsync(x => x.UserId == User.Identity.Name); var branchId = Convert.ToInt32(account.AdminE); var branch = await BetDatabase.Branches.SingleOrDefaultAsync(x => x.BranchId == branchId); var receiptid = bcg.GenerateRandomString(16); var receipt = new Receipt { UserId = User.Identity.Name, BranchId = Convert.ToInt16(account.AdminE), ReceiptStatus = 0, SetNo = 2014927, // ReceiptId = Convert.ToInt32(receiptid) }; //Start New Reciept var betStake = receipts.TotalStake.ToString(CultureInfo.InvariantCulture); string response; BetDatabase.Receipts.Add(receipt); await BetDatabase.SaveChangesAsync(); var ttodd = receipts.TotalOdd; const float bettingLimit = 8000000; var cost = Convert.ToDouble(betStake); if ((cost >= 1000) && (cost <= bettingLimit))//betting limit { foreach (var betData in receipts.BetData) { try { var tempMatchId = Convert.ToInt32(betData.MatchId); var _matchid = BetDatabase.ShortMatchCodes.Single(x => x.ShortCode == tempMatchId).MatchNo; Match _match = BetDatabase.Matches.Single(h => h.MatchNo == _matchid); DateTime _matchTime = _match.StartTime; DateTime timenow = DateTime.Now; if (_matchTime < timenow) { response = ("The Match " + tempMatchId + " Has Started"); return(new JsonResult { Data = new { message = response } }); } var bm = new Bet { BetOptionId = Int32.Parse(betData.OptionId), RecieptId = receipt.ReceiptId, MatchId = BetDatabase.ShortMatchCodes.Single(x => x.ShortCode == tempMatchId).MatchNo, BetOdd = Convert.ToDecimal(betData.Odd), }; BetDatabase.Bets.Add(bm); BetDatabase.SaveChanges(); } catch (Exception er) { response = (" An error has occured:" + er.Message); return(new JsonResult { Data = new { message = response } }); var msg = er.Message; } } // Requires Quick Attention receipt.TotalOdds = Convert.ToDouble(ttodd); receipt.ReceiptStatus = 1; receipt.SetSize = receipts.ReceiptSize; receipt.Stake = cost; receipt.WonSize = 0; receipt.SubmitedSize = 0; receipt.ReceiptDate = DateTime.Now; receipt.Serial = Int2Guid(receiptid); account.DateE = DateTime.Now; // receipt.RecieptID = 34; BetDatabase.Entry(receipt).State = EntityState.Modified; var statement = new Statement { Account = receipt.UserId, Amount = receipt.Stake, Controller = receipt.UserId, StatetmentDate = DateTime.Now, BalBefore = account.AmountE, BalAfter = account.AmountE + receipt.Stake, Comment = "Bet Transaction for Ticket No" + receiptid }; account.AmountE = account.AmountE + receipt.Stake; statement.Transcation = "Teller Bet"; statement.Method = "Online"; statement.Serial = receiptid; branch.Balance = branch.Balance + Convert.ToDecimal(receipt.Stake); BetDatabase.Entry(branch).State = EntityState.Modified; BetDatabase.Accounts.AddOrUpdate(account); BetDatabase.Statements.Add(statement); BetDatabase.SaveChanges(); var barcodeImage = bcg.CreateBarCode(receiptid); var tempPath = Server.MapPath("~/Content/BarCodes/" + receiptid.Trim() + ".png"); try { barcodeImage.Save(tempPath, ImageFormat.Png); } catch (Exception) { } response = ("Success"); } else if (cost < 1000) { receipt.ReceiptId = 0; response = ("Minimum betting stake is UGX 1000. Please enter amount more than UGX 1000."); } else { receipt.ReceiptId = 0; response = ("Maximum stake is UGX " + bettingLimit + ". Please enter amount less than UGX " + bettingLimit + "."); } return(new JsonResult { Data = new { message = response, ReceiptNumber = receipt.ReceiptId, ReceiptTime = String.Format("{0:dd/MM/yyyy}", DateTime.Now) + " - " + toJavaScriptDate(DateTime.Now), TellerName = account.UserId, BranchName = branch.BranchName, Balance = account.AmountE, Serial = receiptid, FormatedSerial = GetSerialNumber(receiptid) } }); }
private async Task <int> UploadGames() { var xmldoc = new XmlDocument(); { xmldoc.Load(Server.MapPath("~/england_shedule.xml")); var categoryList = xmldoc.SelectNodes("/scores/category"); if (categoryList == null) { return(0); } foreach (XmlNode node in categoryList) { var matches = node.ChildNodes; foreach (XmlNode matchesNode in matches) { var games = matchesNode.ChildNodes; foreach (XmlNode gameNode in games) { var home = gameNode.ChildNodes[0]; var away = gameNode.ChildNodes[1]; var odd = gameNode.ChildNodes[4]; var gameOdds = odd.ChildNodes; var league = node.Attributes["name"] != null? node.Attributes["name"].InnerText: "FailedLeague"; var countryName = node.Attributes["file_group"].InnerText; var country = BetDatabase.Countries.SingleOrDefault(c => c.CountryName == countryName); if (country == null) { country = new Country { CountryName = countryName }; BetDatabase.Countries.AddOrUpdate(c => c.CountryName, country); await BetDatabase.SaveChangesAsync(); } // save the league BetDatabase.Leagues.AddOrUpdate(l => l.LeagueName, new League { LeagueName = league, Country = country }); await BetDatabase.SaveChangesAsync(); var game = new Match(); var gameodds = new List <MatchOdd>(); if (home.Name == "localteam") { _homeTeam = new Team { TeamName = home.Attributes["name"].InnerText, CountryId = country.CountryId }; BetDatabase.Teams.AddOrUpdate(t => t.TeamName, _homeTeam); await BetDatabase.SaveChangesAsync(); game.HomeTeamId = _homeTeam.TeamId; } if (away.Name == "visitorteam") { _awayTeam = new Team { TeamName = away.Attributes["name"].InnerText, CountryId = country.CountryId }; BetDatabase.Teams.AddOrUpdate(t => t.TeamName, _awayTeam); await BetDatabase.SaveChangesAsync(); game.AwayTeamId = _awayTeam.TeamId; } char[] del = { '.' }; var stdate = gameNode.Attributes["formatted_date"].InnerText.Split(del); var stDateTime = stdate[1] + "-" + stdate[0] + "-" + stdate[2] + " " + gameNode.Attributes["time"].InnerText + ":00"; var goalServeMatchId = gameNode.Attributes["id"].InnerText; foreach (XmlNode oddType in gameOdds) { var bettype = oddType.Attributes["name"].InnerText; if (bettype.Equals("Full Time Result")) { var normalOdds = oddType.ChildNodes; foreach (XmlNode normalodd in normalOdds) { var choice = normalodd.Attributes.GetNamedItem("name").Value; if (choice == _homeTeam.TeamName + " Win") { gameodds.Add(new MatchOdd { BetOptionId = 1, Odd = Convert.ToDecimal(normalodd.Attributes.GetNamedItem("odd").Value) }); } else if (choice == "Draw") { gameodds.Add(new MatchOdd { BetOptionId = 2, Odd = Convert.ToDecimal(normalodd.Attributes.GetNamedItem("odd").Value) }); } else if (choice == _awayTeam.TeamName + " Win") { gameodds.Add(new MatchOdd { BetOptionId = 3, Odd = Convert.ToDecimal(normalodd.Attributes.GetNamedItem("odd").Value) }); } } } if (bettype.Equals("Double Chance")) { gameodds.AddRange(new[] { new MatchOdd { //1X BetOptionId = 21, Odd = oddType.ChildNodes[2].Attributes != null ? Convert.ToDecimal(oddType.ChildNodes[2].Attributes["odd"].Value) : 0 }, new MatchOdd { //12 BetOptionId = 22, Odd = oddType.ChildNodes[1].Attributes != null ? Convert.ToDecimal(oddType.ChildNodes[1].Attributes["odd"].Value) : 0 }, new MatchOdd { //X2 BetOptionId = 23, Odd = oddType.ChildNodes[0].Attributes != null ? Convert.ToDecimal(oddType.ChildNodes[0].Attributes["odd"].Value) : 0 } }); } else if (bettype.Equals("Half-Time")) { gameodds.AddRange(new[] { new MatchOdd { //1X BetOptionId = 12, Odd = oddType.ChildNodes[0].Attributes != null ? Convert.ToDecimal(oddType.ChildNodes[0].Attributes["odd"].Value) : 0 }, new MatchOdd { //12 BetOptionId = 13, Odd = oddType.ChildNodes[1].Attributes != null ? Convert.ToDecimal(oddType.ChildNodes[1].Attributes["odd"].Value) : 0 }, new MatchOdd { //X2 BetOptionId = 14, Odd = oddType.ChildNodes[2].Attributes != null ? Convert.ToDecimal(oddType.ChildNodes[2].Attributes["odd"].Value) : 0 } }); } else if (bettype.Equals("Handicap Result")) { gameodds.AddRange(new[] { new MatchOdd { BetOptionId = 24, Odd = Convert.ToDecimal(oddType.ChildNodes[0].Attributes["odd"].Value) }, new MatchOdd { BetOptionId = 25, Odd = Convert.ToDecimal(oddType.ChildNodes[1].Attributes["odd"].Value) }, new MatchOdd { BetOptionId = 26, Odd = Convert.ToDecimal(oddType.ChildNodes[2].Attributes["odd"].Value) } }); /*int hhome = * Convert.ToInt16(oddType.ChildNodes[0].Attributes["extravalue"].Value); * int haway = * Convert.ToInt16(oddType.ChildNodes[2].Attributes["extravalue"].Value); * _admin.handhome = hhome < 0 ? (hhome - hhome) : hhome; * _admin.handaway = haway < 0 ? (haway - haway) : haway;*/ } } game.MatchOdds = gameodds; game.BetServiceMatchNo = Convert.ToInt32(goalServeMatchId); game.StartTime = Convert.ToDateTime(stDateTime).ToLocalTime(); game.ResultStatus = 1; game.MatchOdds.ForEach(g => g.BetServiceMatchNo = game.BetServiceMatchNo); BetDatabase.Matches.Add(game); await BetDatabase.SaveChangesAsync(); } } } } return(1); }