public async Task <IActionResult> Edit(int id, [Bind("Id,FirstName,LastName,FullName,Nationality,Earnings,ProfilePicture,CoverPhoto")] Gambler gambler) { if (id != gambler.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(gambler); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!GamblerExists(gambler.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(gambler)); }
public async Task <IActionResult> Create([Bind("Id,HomeTeam,AwayTeam,HomeOdds,DrawOdds,AwayOdds,StartTime,Stadium,HomeGoals,AwayGoals")] Match match) { if (ModelState.IsValid) { _context.Add(match); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(match)); }
public async Task <IActionResult> BetHomeTeam([FromRoute] int id, [Bind("Id,BetMoney")] Ticket tickety) { AppUser curruser = await userManager.GetUserAsync(User); DateTime now = DateTime.Now; var match = await _context.Match.FirstOrDefaultAsync(m => m.Id == id); Ticket ticket = new Ticket { BetTime = now, MatchId = match.Id, BetMoney = tickety.BetMoney, GamblerId = (int)curruser.GamblerId, Tip = 1 }; ticket.WinMoney = ticket.BetMoney * match.HomeOdds * (float)0.85; _context.Add(ticket); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> Create([Bind("Id,BetMoney,Tip,GamblerId")] Ticket ticket) { if (ModelState.IsValid) { DateTime now = DateTime.Now; ticket.BetTime = now; _context.Add(ticket); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["GamblerId"] = new SelectList(_context.Gambler, "Id", "FullName", ticket.GamblerId); ViewData["MatchId"] = new SelectList(_context.Set <Match>(), "Id", "Id", ticket.MatchId); return(View(ticket)); }
public async Task <IActionResult> Create(GamblerViewModel model) { if (ModelState.IsValid) { string uniqueFileName1 = UploadedFile(model); string uniqueFileName2 = UploadedFile2(model); Gambler gambler = new Gambler { FirstName = model.FirstName, LastName = model.LastName, FullName = model.FirstName + " " + model.LastName, Nationality = model.Nationality, Earnings = 0, ProfilePicture = uniqueFileName1, CoverPhoto = uniqueFileName2, }; dbContext.Add(gambler); await dbContext.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View()); }