public async Task <JsonResult> CancelReciept(int id = 0) { var receipt = BetDatabase.Receipts.Find(id); var tellerAccount = await BetDatabase.Accounts.SingleOrDefaultAsync(x => x.UserId == receipt.UserId); if (receipt == null) { return(Json("Receipt Not Found", JsonRequestBehavior.AllowGet)); } tellerAccount.AmountE = tellerAccount.AmountE - receipt.Stake; receipt.ReceiptStatus = -1; var tellerStatement = new Statement { BalBefore = tellerAccount.AmountE, BalAfter = tellerAccount.AmountE, Comment = "Ticket " + receipt.ReceiptId + " Canceling", Transcation = "Reciept Canceling", Account = tellerAccount.UserId, StatetmentDate = DateTime.Now, Controller = User.Identity.Name, }; BetDatabase.Statements.Add(tellerStatement); BetDatabase.Receipts.AddOrUpdate(); BetDatabase.Accounts.AddOrUpdate(); BetDatabase.SaveChanges(); return(Json("Receipt Was Canceled", JsonRequestBehavior.AllowGet)); }
public ActionResult DeleteConfirmed(int id) { var terminal = BetDatabase.Terminals.Find(id); BetDatabase.Terminals.Remove(terminal); BetDatabase.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult DeleteConfirmed(int id) { var branch = BetDatabase.Branches.Find(id); BetDatabase.Branches.Remove(branch); BetDatabase.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult DeleteConfirmed(int id) { var receipt = BetDatabase.Receipts.Find(id); BetDatabase.Receipts.Remove(receipt); BetDatabase.SaveChanges(); return(RedirectToAction("Index")); }
// // GET: /Recept/Delete/5 public async Task <ActionResult> Delete(int id = 0) { var receipt = await BetDatabase.Receipts.FindAsync(id); receipt.ReceiptStatus = -1; BetDatabase.Receipts.AddOrUpdate(); BetDatabase.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Create(Receipt receipt) { if (ModelState.IsValid) { BetDatabase.Receipts.Add(receipt); BetDatabase.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.BranchId = new SelectList(BetDatabase.Branches, "BranchId", "BranchName", receipt.BranchId); return(View(receipt)); }
public ActionResult Edit(Receipt receipt) { if (ModelState.IsValid) { BetDatabase.Entry(receipt).State = EntityState.Modified; BetDatabase.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.BranchId = new SelectList(BetDatabase.Branches, "BranchId", "BranchName", receipt.BranchId); return(View(receipt)); }
public ActionResult Edit(Branch branch) { if (ModelState.IsValid) { BetDatabase.Entry(branch).State = EntityState.Modified; BetDatabase.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.PersonId = new SelectList(UserManager.Users, "PersonId", "FirstName", branch.ManagerId); return(View(branch)); }
public ActionResult Create(Branch branch) { if (ModelState.IsValid) { branch.BranchTypeId = 1; BetDatabase.Branches.Add(branch); BetDatabase.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.PersonId = new SelectList(UserManager.Users, "UserId", "UserName", branch.ManagerId); // ViewBag.CompanyId = new SelectList(BetDatabase.Company, "CompanyId", "CompanyName", branch.CompanyId); return(View(branch)); }
public ActionResult Edit(Terminal terminal) { //var _terminal = new Terminal() //{ // TerminalId = terminal.TerminalId, // IpAddress = terminal.IpAddress, // DateCreated = DateTime.Parse("terminal.DateCreated"), // isActive = false //}; if (ModelState.IsValid) { BetDatabase.Entry(terminal).State = EntityState.Modified; BetDatabase.SaveChanges(); return(RedirectToAction("Index")); } return(View(terminal)); }
public ActionResult Create(Terminal terminal) { if (!ModelState.IsValid) { return(View(terminal)); } { var branch = BetDatabase.Branches.Find(terminal.Branch.BranchId); if (branch != null) { terminal.Branch = branch; } } BetDatabase.Terminals.Add(terminal); BetDatabase.SaveChanges(); return(RedirectToAction("Index")); }
public async Task <JsonResult> PayReciept(int id = 0) { var msg = ""; var receipt = await BetDatabase.Receipts.FindAsync(id); if (receipt == null) { return(Json("Reciept Not Found", JsonRequestBehavior.AllowGet)); } if (receipt.ReceiptStatus != 3) { return(Json(msg, JsonRequestBehavior.AllowGet)); } receipt.ReceiptStatus = 4; var cashierAccount = await BetDatabase.Accounts.SingleOrDefaultAsync(t => t.UserId == User.Identity.Name); var balance = cashierAccount.AmountE; var winAmount = receipt.TotalOdds * receipt.Stake; if (balance > winAmount)//Make Payments { cashierAccount.DateE = DateTime.Now; cashierAccount.AmountE = balance - winAmount; var statement = new Statement { Account = cashierAccount.UserId, BalBefore = cashierAccount.AmountE, Amount = winAmount, BalAfter = cashierAccount.AmountE, Comment = "Payment of Win Ticket Number" + receipt.ReceiptId, Controller = cashierAccount.UserId, Error = false, Transcation = "Ticket Payment", Serial = Convert.ToString(receipt.ReceiptId) }; BetDatabase.Receipts.AddOrUpdate(receipt); BetDatabase.Statements.AddOrUpdate(statement); BetDatabase.Accounts.AddOrUpdate(cashierAccount); BetDatabase.SaveChanges(); return(Json("Reciept Sucessfull", JsonRequestBehavior.AllowGet)); } msg = "You have less money.please contact admin ."; return(Json(msg, JsonRequestBehavior.AllowGet)); }
public async Task <ActionResult> Register(RegisterViewModel model, ApplicationDbContext context) { if (!ModelState.IsValid) { return(View(model)); } var user = new ApplicationUser { UserName = model.UserName, Email = model.Email }; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { await SignInAsync(user, isPersistent : false); var acc = new Account { UserId = model.UserName, AmountE = 0, DateE = DateTime.Now, AdminE = model.BranchId.ToString(CultureInfo.InvariantCulture) }; BetDatabase.Accounts.Add(acc); BetDatabase.SaveChanges(); var manager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(context)); manager.AddToRole(user.Id, model.RoleId); // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771 // Send an email with this link // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>"); return(RedirectToAction("Login", "Account")); } AddErrors(result); ViewBag.BranchId = new SelectList(BetDatabase.Branches, "BranchId", "BranchName"); var roleManager = new RoleManager <IdentityRole>(new RoleStore <IdentityRole>(context)); ViewBag.Roles = new SelectList(roleManager.Roles, "Name", "Name"); // If we got this far, something failed, redisplay form return(View(model)); }
public int AddScores(MatchScores _match) { int AddedScores = 0; int matchNo = _match.MatchNo; int homeGoals = _match.HomeScore; int awayGoals = _match.AwayScore; int homeGoalsHT = _match.HalfTimeHomeScore; int awayGoalsHT = _match.HalfTimeAwayScore; try { DateTime start = DateTime.Now; string goalServeMatchID = matchNo.ToString(); try { int mtcno = Convert.ToInt32(goalServeMatchID); var mtc = BetDatabase.Matches.Include(x => x.AwayTeam).Include(x => x.HomeTeam).Where(c => c.ResultStatus == 1).Single(m => m.BetServiceMatchNo == mtcno); if (mtc == null) { } // Match mtc = BetDatabase.Matches.Where(mt => mt.BetServiceMatchNo == mtcno).SingleOrDefault(); try { mtc.HomeScore = homeGoals; mtc.AwayScore = awayGoals; mtc.HalfTimeAwayScore = awayGoalsHT; mtc.HalfTimeHomeScore = homeGoalsHT; mtc.ResultStatus = 2; // BetDatabase.Matches.Attach(mtc); BetDatabase.Entry(mtc).State = EntityState.Modified; BetDatabase.SaveChanges(); AddedScores++; } catch (DbEntityValidationException ex) { StringBuilder sb = new StringBuilder(); foreach (var failure in ex.EntityValidationErrors) { sb.AppendFormat("{0} failed validation\n", failure.Entry.Entity.GetType()); foreach (var error in failure.ValidationErrors) { sb.AppendFormat("- {0} : {1}", error.PropertyName, error.ErrorMessage); sb.AppendLine(); } } string msg = sb.ToString(); } List <Result> resultList = new List <Result>(); /* Match Results*/ if (mtc.HomeScore > mtc.AwayScore) { Result result = new Result(); result.MatchId = mtc.BetServiceMatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 1).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(h => h.BetCategoryId == result.CategoryId).Where(c => c.BetOptionId == 1).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); resultList.Add(result); } else if (mtc.HomeScore < mtc.AwayScore) { Result result = new Result(); result.MatchId = mtc.BetServiceMatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 1).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(h => h.BetCategoryId == result.CategoryId).Where(c => c.BetOptionId == 3).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); resultList.Add(result); } else if (mtc.HomeScore == mtc.AwayScore) { Result result = new Result(); result.MatchId = mtc.BetServiceMatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 1).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(h => h.BetCategoryId == result.CategoryId).Where(c => c.BetOptionId == 2).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); resultList.Add(result); } /*End Match Result */ /* HaltTime Results*/ if (mtc.HalfTimeHomeScore > mtc.HalfTimeAwayScore) { Result result = new Result(); result.MatchId = mtc.BetServiceMatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 3).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(h => h.BetCategoryId == result.CategoryId).Where(c => c.BetOptionId == 12).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); resultList.Add(result); } else if (mtc.HalfTimeHomeScore < mtc.HalfTimeAwayScore) { Result result = new Result(); result.MatchId = mtc.BetServiceMatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 3).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(h => h.BetCategoryId == result.CategoryId).Where(c => c.BetOptionId == 14).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); resultList.Add(result); } else if (mtc.HalfTimeHomeScore == mtc.HalfTimeAwayScore) { Result result = new Result(); result.MatchId = mtc.BetServiceMatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 3).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(h => h.BetCategoryId == result.CategoryId).Where(c => c.BetOptionId == 13).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); resultList.Add(result); } /*End HalfTime Result */ ///*Start Draw No Bet*/ //if (mtc.HomeScore > mtc.AwayScore) //{ // Result result = new Result(); // result.MatchId = mtc.BetServiceMatchNo; // result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 9).FirstOrDefault().CategoryId; // result.OptionId = BetDatabase.BetOptions.Where(h => h.BetCategoryId == result.CategoryId).Where(c => c.BetOptionId == 13).FirstOrDefault().BetOptionId; // BetDatabase.Results.Add(result); // resultList.Add(result); // BetDatabase.SaveChanges(); //} //else if (mtc.HomeScore < mtc.AwayScore) //{ // Result result = new Result(); // result.MatchId = mtc.BetServiceMatchNo; // result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 9).FirstOrDefault().CategoryId; // result.OptionId = BetDatabase.BetOptions.Where(h => h.BetCategoryId == result.CategoryId).Where(c => c.Option == "DNB2").FirstOrDefault().BetOptionId; // BetDatabase.Results.Add(result); // resultList.Add(result); // BetDatabase.SaveChanges(); //} //else if (mtc.HomeScore == mtc.AwayScore) //{ // Result result = new Result(); // result.MatchId = mtc.BetServiceMatchNo; // result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 9).FirstOrDefault().CategoryId; // result.OptionId = BetDatabase.BetOptions.Where(h => h.BetCategoryId == result.CategoryId).Where(c => c.Option == "DNB2").FirstOrDefault().BetOptionId; // BetDatabase.Results.Add(result); // resultList.Add(result); // BetDatabase.SaveChanges(); //} ///*End Match Result */ /* Start Double Chance*/ if (mtc.HomeScore > mtc.AwayScore) { Result result = new Result(); result.MatchId = mtc.BetServiceMatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 9).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 21).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 22).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); resultList.Add(result); } else if (mtc.HomeScore < mtc.AwayScore) { Result result = new Result(); result.MatchId = mtc.BetServiceMatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 4).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 23).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 22).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); resultList.Add(result); } else if (mtc.HomeScore == mtc.AwayScore) { Result result = new Result(); result.MatchId = mtc.BetServiceMatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 2).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 23).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 21).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); resultList.Add(result); } /*End Double Chance */ /* Start Unders Over*/ /* Full Time Total Goals or Wire or underover*/ int FullTimeTotalGoals = (int)(mtc.HomeScore + mtc.AwayScore); if (FullTimeTotalGoals > 0.5) //over 0.5 { Result result = new Result(); result.MatchId = mtc.BetServiceMatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 2).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 33).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); resultList.Add(result); } else if (FullTimeTotalGoals < 0.5) //under0.5 { Result result = new Result(); result.MatchId = mtc.BetServiceMatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 2).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 32).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); resultList.Add(result); } if (FullTimeTotalGoals > 1.5) { Result result = new Result(); result.MatchId = mtc.BetServiceMatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 2).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 5).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); resultList.Add(result); } else if (FullTimeTotalGoals < 1.5) { Result result = new Result(); result.MatchId = mtc.BetServiceMatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 2).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 4).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); resultList.Add(result); } if (FullTimeTotalGoals > 2.5) { Result result = new Result(); result.MatchId = mtc.BetServiceMatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 2).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 7).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); resultList.Add(result); } else if (FullTimeTotalGoals < 2.5) { Result result = new Result(); result.MatchId = mtc.BetServiceMatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 2).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 6).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); resultList.Add(result); } if (FullTimeTotalGoals > 3.5) { Result result = new Result(); result.MatchId = mtc.BetServiceMatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 2).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 9).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); resultList.Add(result); } else if (FullTimeTotalGoals < 3.5) { Result result = new Result(); result.MatchId = mtc.BetServiceMatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 2).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 8).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); resultList.Add(result); } if (FullTimeTotalGoals > 4.5) { Result result = new Result(); result.MatchId = mtc.BetServiceMatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 2).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 11).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); resultList.Add(result); } else if (FullTimeTotalGoals < 4.5) { Result result = new Result(); result.MatchId = mtc.BetServiceMatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 2).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 12).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); resultList.Add(result); } if (FullTimeTotalGoals > 5.5) { Result result = new Result(); result.MatchId = mtc.BetServiceMatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 2).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 35).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); resultList.Add(result); } else if (FullTimeTotalGoals < 5.5) { Result result = new Result(); result.MatchId = mtc.BetServiceMatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 2).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 34).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); resultList.Add(result); } /*End FullTime U/O/ * * * /*Start HalfTime Unders Over */ /* 0.5 */ int HalfTimeTotalGoals = (int)(mtc.HalfTimeHomeScore + mtc.HalfTimeAwayScore); if (HalfTimeTotalGoals > 0.5) { Result result = new Result(); result.MatchId = mtc.BetServiceMatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 4).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 16).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); resultList.Add(result); } else if (HalfTimeTotalGoals < 0.5) { Result result = new Result(); result.MatchId = mtc.BetServiceMatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 2).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 15).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); resultList.Add(result); } /* 0.5*/ /*1.5*/ if (HalfTimeTotalGoals > 1.5) { Result result = new Result(); result.MatchId = mtc.BetServiceMatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 4).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 18).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); resultList.Add(result); } else if (HalfTimeTotalGoals < 1.5) { Result result = new Result(); result.MatchId = mtc.BetServiceMatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 4).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 17).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); BetDatabase.SaveChanges(); resultList.Add(result); } /*1.5*/ /*2.5 */ if (HalfTimeTotalGoals > 2.5) { Result result = new Result(); result.MatchId = mtc.BetServiceMatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 4).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 20).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); resultList.Add(result); } else if (HalfTimeTotalGoals < 2.5) { Result result = new Result(); result.MatchId = mtc.BetServiceMatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 4).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 19).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); resultList.Add(result); } /* HT2.5*/ /* End 2.5*/ /*End Half Time Unders/Overs * /* Both Teams To Score*/ if ((homeGoals > 0) && (awayGoals > 0)) { Result result = new Result(); result.MatchId = mtc.BetServiceMatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 7).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 26).Where(l => l.BetCategoryId == result.CategoryId).FirstOrDefault().BetCategoryId; BetDatabase.Results.Add(result); resultList.Add(result); } else if ((homeGoals == 0) && (awayGoals == 0)) { Result result = new Result(); result.MatchId = mtc.BetServiceMatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 7).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 27).Where(l => l.BetCategoryId == result.CategoryId).FirstOrDefault().BetCategoryId; BetDatabase.Results.Add(result); resultList.Add(result); } /*End unders Both Teams To Score*/ foreach (Result score in resultList) { List <Bet> betted = new List <Bet>(); betted = BetDatabase.Bets.Include(f => f.Receipt).Where(s => s.MatchId == score.MatchId).Where(j => j.BetOption.BetCategoryId == score.CategoryId).Where(r => r.GameBetStatus == 0).ToList(); foreach (Bet bm in betted) { Receipt rec = BetDatabase.Receipts.Where(rc => rc.ReceiptId == bm.RecieptId).Where(rc => rc.ReceiptStatus == 1).SingleOrDefault(); if (rec == null) { continue; } rec.SubmitedSize = rec.SubmitedSize + 1; if ((bm.BetOptionId == score.OptionId) && (bm.BetOption.BetCategoryId == score.CategoryId)) { rec.WonSize = rec.WonSize + 1; bm.GameBetStatus = 2; } else if ((score.CategoryId == 2) || (score.CategoryId == 4)) { int subCategory = getSubCategory(score.OptionId); int baseCategory = getSubCategory(bm.BetOptionId); if (UnderOverCat(subCategory, baseCategory)) { rec.ReceiptStatus = 2; bm.GameBetStatus = 1; } else { continue; } } else { rec.ReceiptStatus = 2; bm.GameBetStatus = 1; } BetDatabase.Entry(bm).State = EntityState.Modified; // BetDatabase.Entry(bm).Entity = EntityState.Modified; } } BetDatabase.SaveChanges(); List <Receipt> WonReciepts = new List <Receipt>(); WonReciepts = BetDatabase.Receipts.Where(w => w.SetSize == w.WonSize).Where(s => s.ReceiptStatus == 1).ToList(); if (WonReciepts.Count > 0) { foreach (Receipt wonrec in WonReciepts) { wonrec.ReceiptStatus = 3; } BetDatabase.SaveChanges(); } } catch (Exception e) { string msg = e.Message; } } catch (Exception exception) { } return(AddedScores); }
public async Task <JsonResult> SaveLists(List <String> id) { // Deserialize it to a dictionary // var dic = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<String, dynamic>>(jsonString); var result = String.Format("Fist item in list: '{0}'", id[0]); var betStake = id[0]; var userBalance = id[0]; int games = Convert.ToInt16(id[0]); var receipt = new Receipt(); var bcg = new BarCodeGenerator(); var betcat = new BetCategory(); const double ttodd = 1; const float bettingLimit = 800000; if (Convert.ToDecimal(betStake) >= Convert.ToDecimal(userBalance)) { return(Json(new { Result = result, RecieptTime = DateTime.Now, RecieptNumber = receipt.ReceiptId }, JsonRequestBehavior.AllowGet)); } var cost = Convert.ToDouble(betStake); if ((cost >= 1000) && (cost <= bettingLimit))//betting limit { var all = (ArrayList)(Session["Current_bets"]); var gameNumbers = new int[games]; for (var i = 0; i < games; i++) { var bet = (string[])all[i]; gameNumbers[i] = Convert.ToInt32(bet[0]); } var receiptid = bcg.GenerateRandomString(7); if (receiptid != "") { } for (var i = 0; i < games; i++) { var bet = (string[])all[i]; var matchno = bet[0]; var choice = bet[4]; try { //Straight bet if (choice.Equals("H") || choice.Equals("A") || choice.Equals("X")) { choice = bet[4].Equals("H") ? "Home" : (bet[4].Equals("A") ? "Away" : "Draw"); betcat.Name = "Straight"; } //wire bet else if (choice.Equals("U") || choice.Equals("O")) { choice = bet[4].Equals("U") ? "Under" : "Over"; betcat.Name = "wire"; } //double chance bet else if (choice.Equals("1X") || choice.Equals("2X") || choice.Equals("12")) { betcat.Name = "dc"; } //halftime bet else if (choice.Equals("H1") || choice.Equals("HX") || choice.Equals("H2")) { choice = bet[4].Equals("H1") ? "Home" : (bet[4].Equals("H2") ? "Away" : "Draw"); betcat.Name = "halftime"; } //handicap bet else if (choice.Equals("HC1") || choice.Equals("HCX") || choice.Equals("HC2")) { choice = bet[4].Equals("HC1") ? "Home" : (bet[4].Equals("HC2") ? "Away" : "Draw"); betcat.Name = "hc"; } //wire bet else if (choice.Equals("OD") || choice.Equals("EV")) { choice = bet[4].Equals("OD") ? "Odd" : "Even"; betcat.Name = "oddeven"; } var bm = new Bet { MatchId = Convert.ToInt32(matchno), RecieptId = Convert.ToInt32(receiptid) //bm.odd = 3; //bm.betcategory = 1; //bm.matchstatus = ""; }; } catch (Exception er) { var msg = er.Message; } } receipt.ReceiptDate = DateTime.Now; receipt.TotalOdds = Convert.ToDouble(ttodd); receipt.ReceiptStatus = 1; //receipt.submitedsize = 0; //receipt.wonsize = 0; //receipt.setsize = games; receipt.Stake = cost; receipt.UserId = Session["username"].ToString(); BetDatabase.Receipts.Add(receipt); var account = await BetDatabase.Accounts.SingleOrDefaultAsync(x => x.UserId == receipt.UserId); account.AmountE += receipt.Stake; account.DateE = DateTime.Now; BetDatabase.Accounts.AddOrUpdate(account); BetDatabase.SaveChanges(); } else if (cost < 1000) { } return(Json(new { Result = result, RecieptTime = DateTime.Now, RecieptNumber = receipt.ReceiptId }, JsonRequestBehavior.AllowGet)); }
public ActionResult AddPayment(Payment payment) { payment.PaymentDate = DateTime.Now; var acc = BetDatabase.Accounts.SingleOrDefault(m => m.UserId == payment.UserId); if (acc == null) { return(Json(new Notification() { Successful = false, Message = "An error occured, this teller account does not exist. Contact the systems administrator for help." }, JsonRequestBehavior.AllowGet)); } if (payment.TransType == "From Account") { acc.AmountE = acc.AmountE - payment.AmountPaid; var statement = new Statement { BalBefore = acc.AmountE, Amount = payment.AmountPaid, Transcation = "Money Transfer", StatetmentDate = DateTime.Now, Account = acc.UserId, Comment = "Teller Deposit", BalAfter = acc.AmountE }; BetDatabase.Accounts.AddOrUpdate(acc); BetDatabase.Statements.Add(statement); BetDatabase.SaveChanges(); var managerAcc = BetDatabase.Accounts.SingleOrDefault(m => m.UserId == User.Identity.Name); if (managerAcc == null) { return(Json(new Notification() { Successful = false, Message = "An error occured, this manager account does not exist. Contact the systems administrator for help." }, JsonRequestBehavior.AllowGet)); } ; managerAcc.AmountE = managerAcc.AmountE + payment.AmountPaid; var managerStatement = new Statement { BalBefore = acc.AmountE, Amount = payment.AmountPaid, Transcation = "Money Transfer", StatetmentDate = DateTime.Now, Account = managerAcc.UserId, Comment = "Teller Transfer From " + acc.UserId + " To " + managerAcc.UserId, BalAfter = acc.AmountE }; BetDatabase.Accounts.AddOrUpdate(managerAcc); BetDatabase.Statements.Add(managerStatement); BetDatabase.SaveChanges(); return(Json(new Notification() { Successful = true, Message = "Payment from account was made successfully." }, JsonRequestBehavior.AllowGet)); } else if (payment.TransType == "To Account") { acc.AmountE = acc.AmountE + payment.AmountPaid; var statement = new Statement { BalBefore = acc.AmountE, Amount = payment.AmountPaid, Transcation = "Transfer ", StatetmentDate = DateTime.Now, Account = acc.UserId, Comment = "Manager Transfer To Teller", BalAfter = acc.AmountE }; BetDatabase.Accounts.AddOrUpdate(acc); BetDatabase.Statements.Add(statement); BetDatabase.SaveChanges(); var managerAcc = BetDatabase.Accounts.SingleOrDefault(m => m.UserId == User.Identity.Name); if (managerAcc == null) { return(Json(new Notification { Successful = false, Message = "An error occured, this manager account does not exist. Contact the systems administrator for help." }, JsonRequestBehavior.AllowGet)); } managerAcc.AmountE = managerAcc.AmountE + payment.AmountPaid; var managerStatement = new Statement { BalBefore = acc.AmountE, Amount = payment.AmountPaid, Transcation = "Money Transfer", StatetmentDate = DateTime.Now, Account = managerAcc.UserId, Comment = "Teller Transfer From " + acc.UserId + " To " + managerAcc.UserId, BalAfter = acc.AmountE }; BetDatabase.Accounts.AddOrUpdate(managerAcc); BetDatabase.Statements.Add(managerStatement); BetDatabase.SaveChanges(); return(Json(new Notification() { Successful = true, Message = "Payment to account was made successfully." }, JsonRequestBehavior.AllowGet)); } return(Json(new Notification { Successful = false, Message = "An error occured while saving entries to the database. Contact the systems administrator for help." }, JsonRequestBehavior.AllowGet)); }
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) } }); }
public void score() { try { if (!AlreadyRunningUpdate) { //AlreadyRunningUpdate = true; DateTime start = DateTime.Now; foreach (var iURL in _resultUrls) { var req = (HttpWebRequest)WebRequest.Create(iURL); var res = (HttpWebResponse)req.GetResponse(); var stream = res.GetResponseStream(); var xmldoc = new XmlDocument(); xmldoc.Load(stream); var categoryList = xmldoc.SelectNodes("/scores/category"); int loops = 0; string goalServeMatchID = ""; foreach (XmlNode categoryNode in categoryList) { XmlNodeList matches = categoryNode.ChildNodes; foreach (XmlNode matchesNode in matches) { loops += 1; XmlNodeList games = matchesNode.ChildNodes; foreach (XmlNode gameNode in games) { string status = gameNode.Attributes["status"].InnerText.ToString(); if (status == "FT")//update for only full time games { XmlNode home = gameNode.ChildNodes[0]; XmlNode away = gameNode.ChildNodes[1]; XmlNode halftime = gameNode.ChildNodes[3]; string hostTeam = home.Attributes["name"].InnerText; string awayTeam = away.Attributes["name"].InnerText; goalServeMatchID = gameNode.Attributes["id"].InnerText; try { int homeGoals = Convert.ToInt16(home.Attributes["goals"].InnerText); int awayGoals = Convert.ToInt16(away.Attributes["goals"].InnerText); string half_time = halftime.Attributes["score"].InnerText; //format[3-2] char[] del2 = { '-' }; string[] hf = half_time.Substring(1, half_time.Length - 2).Split(del2); int homeGoalsHT = Convert.ToInt16(hf[0]); int awayGoalsHT = Convert.ToInt16(hf[1]); int mtcno = Convert.ToInt32(goalServeMatchID); var mtc = BetDatabase.Matches.Include(x => x.AwayTeam).Include(x => x.HomeTeam).Single(m => m.MatchNo == mtcno); if (mtc == null) { countFail++; continue; } // Match mtc = BetDatabase.Matches.Where(mt => mt.MatchNo == mtcno).SingleOrDefault(); try { mtc.HomeScore = homeGoals; mtc.AwayScore = awayGoals; mtc.HalfTimeAwayScore = awayGoalsHT; mtc.HalfTimeHomeScore = homeGoalsHT; // BetDatabase.Matches.Attach(mtc); BetDatabase.Entry(mtc).State = EntityState.Modified; BetDatabase.SaveChanges(); } catch (DbEntityValidationException ex) { StringBuilder sb = new StringBuilder(); foreach (var failure in ex.EntityValidationErrors) { sb.AppendFormat("{0} failed validation\n", failure.Entry.Entity.GetType()); foreach (var error in failure.ValidationErrors) { sb.AppendFormat("- {0} : {1}", error.PropertyName, error.ErrorMessage); sb.AppendLine(); } } string msg = sb.ToString(); } List <Result> resultList = new List <Result>(); /* Match Results*/ if (mtc.HomeScore > mtc.AwayScore) { Result result = new Result(); result.MatchId = mtc.MatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 1).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(h => h.BetCategoryId == result.CategoryId).Where(c => c.BetOptionId == 1).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); resultList.Add(result); BetDatabase.SaveChanges(); } else if (mtc.HomeScore < mtc.AwayScore) { Result result = new Result(); result.MatchId = mtc.MatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 1).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(h => h.BetCategoryId == result.CategoryId).Where(c => c.BetOptionId == 3).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); resultList.Add(result); BetDatabase.SaveChanges(); } else if (mtc.HomeScore == mtc.AwayScore) { Result result = new Result(); result.MatchId = mtc.MatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 1).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(h => h.BetCategoryId == result.CategoryId).Where(c => c.BetOptionId == 2).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); resultList.Add(result); } /*End Match Result */ /* HaltTime Results*/ if (mtc.HalfTimeHomeScore > mtc.HalfTimeAwayScore) { Result result = new Result(); result.MatchId = mtc.MatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 3).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(h => h.BetCategoryId == result.CategoryId).Where(c => c.BetOptionId == 12).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); resultList.Add(result); BetDatabase.SaveChanges(); } else if (mtc.HalfTimeHomeScore < mtc.HalfTimeAwayScore) { Result result = new Result(); result.MatchId = mtc.MatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 3).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(h => h.BetCategoryId == result.CategoryId).Where(c => c.BetOptionId == 14).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); resultList.Add(result); BetDatabase.SaveChanges(); } else if (mtc.HalfTimeHomeScore == mtc.HalfTimeAwayScore) { Result result = new Result(); result.MatchId = mtc.MatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 3).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(h => h.BetCategoryId == result.CategoryId).Where(c => c.BetOptionId == 13).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); resultList.Add(result); } /*End HalfTime Result */ ///*Start Draw No Bet*/ //if (mtc.HomeScore > mtc.AwayScore) //{ // Result result = new Result(); // result.MatchId = mtc.MatchNo; // result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 9).FirstOrDefault().CategoryId; // result.OptionId = BetDatabase.BetOptions.Where(h => h.BetCategoryId == result.CategoryId).Where(c => c.BetOptionId == 13).FirstOrDefault().BetOptionId; // BetDatabase.Results.Add(result); // resultList.Add(result); // BetDatabase.SaveChanges(); //} //else if (mtc.HomeScore < mtc.AwayScore) //{ // Result result = new Result(); // result.MatchId = mtc.MatchNo; // result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 9).FirstOrDefault().CategoryId; // result.OptionId = BetDatabase.BetOptions.Where(h => h.BetCategoryId == result.CategoryId).Where(c => c.Option == "DNB2").FirstOrDefault().BetOptionId; // BetDatabase.Results.Add(result); // resultList.Add(result); // BetDatabase.SaveChanges(); //} //else if (mtc.HomeScore == mtc.AwayScore) //{ // Result result = new Result(); // result.MatchId = mtc.MatchNo; // result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 9).FirstOrDefault().CategoryId; // result.OptionId = BetDatabase.BetOptions.Where(h => h.BetCategoryId == result.CategoryId).Where(c => c.Option == "DNB2").FirstOrDefault().BetOptionId; // BetDatabase.Results.Add(result); // resultList.Add(result); // BetDatabase.SaveChanges(); //} ///*End Match Result */ /* Start Double Chance*/ if (mtc.HomeScore > mtc.AwayScore) { Result result = new Result(); result.MatchId = mtc.MatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 9).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 21).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 22).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); resultList.Add(result); } else if (mtc.HomeScore < mtc.AwayScore) { Result result = new Result(); result.MatchId = mtc.MatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 4).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 23).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 22).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); resultList.Add(result); } else if (mtc.HomeScore == mtc.AwayScore) { Result result = new Result(); result.MatchId = mtc.MatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 2).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 23).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 21).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); resultList.Add(result); } /*End Double Chance */ /* Start Unders Over*/ /* Full Time Total Goals or Wire or underover*/ int FullTimeTotalGoals = (int)(mtc.HomeScore + mtc.AwayScore); if (FullTimeTotalGoals > 0.5)//over 0.5 { Result result = new Result(); result.MatchId = mtc.MatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 2).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 33).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); resultList.Add(result); } else if (FullTimeTotalGoals < 0.5) //under0.5 { Result result = new Result(); result.MatchId = mtc.MatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 2).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 32).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); BetDatabase.SaveChanges(); resultList.Add(result); } if (FullTimeTotalGoals > 1.5) { Result result = new Result(); result.MatchId = mtc.MatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 2).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 5).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); resultList.Add(result); } else if (FullTimeTotalGoals < 1.5) { Result result = new Result(); result.MatchId = mtc.MatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 2).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 4).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); BetDatabase.SaveChanges(); resultList.Add(result); } if (FullTimeTotalGoals > 2.5) { Result result = new Result(); result.MatchId = mtc.MatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 2).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 7).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); resultList.Add(result); } else if (FullTimeTotalGoals < 2.5) { Result result = new Result(); result.MatchId = mtc.MatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 2).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 6).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); BetDatabase.SaveChanges(); resultList.Add(result); } if (FullTimeTotalGoals > 3.5) { Result result = new Result(); result.MatchId = mtc.MatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 2).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 9).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); resultList.Add(result); } else if (FullTimeTotalGoals < 3.5) { Result result = new Result(); result.MatchId = mtc.MatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 2).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 8).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); BetDatabase.SaveChanges(); resultList.Add(result); } if (FullTimeTotalGoals > 4.5) { Result result = new Result(); result.MatchId = mtc.MatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 2).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 11).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); resultList.Add(result); } else if (FullTimeTotalGoals < 4.5) { Result result = new Result(); result.MatchId = mtc.MatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 2).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 12).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); BetDatabase.SaveChanges(); resultList.Add(result); } if (FullTimeTotalGoals > 5.5) { Result result = new Result(); result.MatchId = mtc.MatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 2).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 35).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); resultList.Add(result); } else if (FullTimeTotalGoals < 5.5) { Result result = new Result(); result.MatchId = mtc.MatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 2).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 34).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); BetDatabase.SaveChanges(); resultList.Add(result); } /*End FullTime U/O/ * * * /*Start HalfTime Unders Over */ /* 0.5 */ int HalfTimeTotalGoals = (int)(mtc.HalfTimeHomeScore + mtc.HalfTimeAwayScore); if (HalfTimeTotalGoals > 0.5) { Result result = new Result(); result.MatchId = mtc.MatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 4).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 16).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); resultList.Add(result); } else if (HalfTimeTotalGoals < 0.5) { Result result = new Result(); result.MatchId = mtc.MatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 2).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 15).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); BetDatabase.SaveChanges(); resultList.Add(result); } /* 0.5*/ /*1.5*/ if (HalfTimeTotalGoals > 1.5) { Result result = new Result(); result.MatchId = mtc.MatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 4).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 18).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); resultList.Add(result); } else if (HalfTimeTotalGoals < 1.5) { Result result = new Result(); result.MatchId = mtc.MatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 4).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 17).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); BetDatabase.SaveChanges(); resultList.Add(result); } /*1.5*/ /*2.5 */ if (HalfTimeTotalGoals > 2.5) { Result result = new Result(); result.MatchId = mtc.MatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 4).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 20).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); resultList.Add(result); } else if (HalfTimeTotalGoals < 2.5) { Result result = new Result(); result.MatchId = mtc.MatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 4).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 19).FirstOrDefault().BetOptionId; BetDatabase.Results.Add(result); BetDatabase.SaveChanges(); resultList.Add(result); } /* HT2.5*/ /* End 2.5*/ /*End Half Time Unders/Overs * /* Both Teams To Score*/ if ((homeGoals > 0) && (awayGoals > 0)) { Result result = new Result(); result.MatchId = mtc.MatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 7).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 26).Where(l => l.BetCategoryId == result.CategoryId).FirstOrDefault().BetCategoryId; BetDatabase.Results.Add(result); resultList.Add(result); } else if ((homeGoals == 0) && (awayGoals == 0)) { Result result = new Result(); result.MatchId = mtc.MatchNo; result.CategoryId = BetDatabase.BetCategories.Where(c => c.CategoryId == 7).FirstOrDefault().CategoryId; result.OptionId = BetDatabase.BetOptions.Where(c => c.BetOptionId == 27).Where(l => l.BetCategoryId == result.CategoryId).FirstOrDefault().BetCategoryId; BetDatabase.Results.Add(result); resultList.Add(result); } /*End unders Both Teams To Score*/ foreach (Result score in resultList) { List <Bet> betted = new List <Bet>(); betted = BetDatabase.Bets.Include(f => f.Receipt).Where(s => s.MatchId == score.MatchId).Where(j => j.BetOption.BetCategoryId == score.CategoryId).Where(r => r.GameBetStatus == 0).ToList(); foreach (Bet bm in betted) { Receipt rec = BetDatabase.Receipts.Where(rc => rc.ReceiptId == bm.RecieptId).Where(rc => rc.ReceiptStatus == 1).SingleOrDefault(); if (rec == null) { continue; } rec.SubmitedSize = rec.SubmitedSize + 1; //if (score.OptionId == 30) //{ // betted = BetDatabase.Bets.Where(s => s.MatchId == score.MatchId).Where(j => j.BetOption.BetCategoryId == score.CategoryId).ToList(); // foreach (var bet in betted) // { // Receipt betReciept = BetDatabase.Receipts.Where(rc => rc.ReceiptId == bm.RecieptId).Where(rc => rc.ReceiptStatus == 1).SingleOrDefault(); // Double Divider =Convert.ToDouble( betReciept.TotalOdds); // // betReciept.TotalOdds =Convert.ToDecimal(betReciept.TotalOdds/(Divider)); // } //} if ((bm.BetOptionId == score.OptionId) && (bm.BetOption.BetCategoryId == score.CategoryId)) { rec.WonSize = rec.WonSize + 1; bm.GameBetStatus = 2; } else { rec.ReceiptStatus = 2; bm.GameBetStatus = 1; } BetDatabase.Entry(bm).State = EntityState.Modified; // BetDatabase.Entry(bm).Entity = EntityState.Modified; } } BetDatabase.SaveChanges(); List <Receipt> WonReciepts = new List <Receipt>(); WonReciepts = BetDatabase.Receipts.Where(w => w.SetSize == w.WonSize).Where(s => s.ReceiptStatus == 1).ToList(); if (WonReciepts.Count > 0) { foreach (Receipt wonrec in WonReciepts) { wonrec.ReceiptStatus = 3; } BetDatabase.SaveChanges(); } } catch (Exception e) { string msg = e.Message; countFail++; continue; } } } //end game } //end matches // LbResult.Text = loops.ToString(); } //end category, xml parse try { xmldoc.Load(new MemoryStream()); } catch (Exception ex) { } Thread.Sleep(5000); } var totalTime = (DateTime.Now - start); // }); respond("Success score updates: " + count + "<br />Pending/Failed: " + countFail); } else { respond("<b><font color=\"Red\">Update is already running in the background</font></b>"); } } catch (Exception exception) { } AlreadyRunningUpdate = false; }