private bool ValidateForPlay(Wedstrijd wedstrijd) { bool validated = true; Message.Clear(); if (wedstrijd.IsGespeeld) { Message.AddLineToMessageBody($"Wedstrijd {wedstrijd.NaamToString} is al gespeeld"); validated = false; } if (wedstrijd.IsBezig) { Message.AddLineToMessageBody($"Wedstrijd {wedstrijd.NaamToString} is bezig"); validated = false; } if (wedstrijd.ThuisTeam.TeamLeden.Count() < 4) { validated = false; Message.AddLineToMessageBody($"{wedstrijd.ThuisTeam.NaamToString} heeft te weinig spelers (min 4)"); } if (wedstrijd.UitTeam.TeamLeden.Count() < 4) { validated = false; Message.AddLineToMessageBody($"{wedstrijd.UitTeam.NaamToString} heeft te weinig spelers (min 4)"); } return(validated); }
public IActionResult VoegWedstrijdToe(Wedstrijd wedstrijd) { int i = 1; for (int j = 0; j < _context.Wedstrijden.Count(); j++) { List <Wedstrijd> lijst = _context.Wedstrijden.ToList(); if (i == lijst[j].ID) { i++; } else { break; } } if (ModelState.IsValid) { try { wedstrijd.ID = i; _context.Add(wedstrijd); _context.SaveChanges(); } catch (DbUpdateConcurrencyException) { throw; } return(RedirectToAction("Index", "Maintain")); } return(View(wedstrijd)); }
public IActionResult NieuweWedstrijd(WedstrijdViewModel spelerwedstrijd) { if (ModelState.IsValid && (spelerwedstrijd.IdSpeler1 != spelerwedstrijd.IdSpeler2)) { try { Speler speler1 = _spelerRepository.GetById(spelerwedstrijd.IdSpeler1); Speler speler2 = _spelerRepository.GetById(spelerwedstrijd.IdSpeler2); Wedstrijd w = new Wedstrijd(spelerwedstrijd.DatumGespeeld); SpelerWedstrijd sw1 = new SpelerWedstrijd(speler1, w, spelerwedstrijd.PuntenGewonnen, speler2.Voornaam + " " + speler2.Naam); SpelerWedstrijd sw2 = new SpelerWedstrijd(speler2, w, spelerwedstrijd.PuntenVerloren, speler1.Voornaam + " " + speler1.Naam); _spelerWedstrijdRepository.Add(sw1); _spelerWedstrijdRepository.Add(sw2); _spelerWedstrijdRepository.SaveChanges(); TempData["message"] = $"Nieuwe wedstrijd tussen {speler1.VolledigeNaam} en {speler2.VolledigeNaam} werd met succes toegevoegd!"; return(RedirectToAction(nameof(Index))); } catch (Exception e) { ModelState.AddModelError("", e.Message); } } ViewData["Spelers"] = GetSpelersAsSelectList(); return(View()); }
public async Task <ActionResult <Wedstrijd> > PostWedstrijd(Wedstrijd wedstrijd) { _context.Wedstrijden.Add(wedstrijd); await _context.SaveChangesAsync(); return(Ok(wedstrijd)); }
public void ValideerWedstrijdEnVoegToe(Wedstrijd wedstrijd) { if (ValidateWedstrijd(wedstrijd)) { _dataBaseRepository.VoegNieuwItemToe(wedstrijd); } }
public async Task <ActionResult <Wedstrijd> > PutWedstrijd(int id, Wedstrijd wedstrijd) { if (id != wedstrijd.WedstrijdID) { return(BadRequest()); } _context.Entry(wedstrijd).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!WedstrijdExists(id)) { return(NotFound()); } else { throw; } } return(wedstrijd); }
public void VerwijderWedstrijd(Wedstrijd wedstrijd) { if (!(wedstrijd.IsBezig || wedstrijd.IsGespeeld)) { _dataBaseRepository.VerwijderItem(wedstrijd); } }
private Wedstrijd SimuleerWedstrijd(Wedstrijd wedstrijd) { wedstrijd.ScoreThuis = GetRandomScore(5); wedstrijd.ScoreUit = GetRandomScore(5); //Knockout Fases if (wedstrijd.KnockoutID != null) { //Verleningen if (wedstrijd.IsGelijkSpel) { wedstrijd.ScoreThuis += GetRandomScore(2); wedstrijd.ScoreUit += GetRandomScore(2); } //Penalties if (wedstrijd.IsGelijkSpel) { wedstrijd.ScoreThuis += GetRandomScore(5); wedstrijd.ScoreUit += GetRandomScore(5); } while (wedstrijd.IsGelijkSpel) { wedstrijd.ScoreThuis += GetRandomScore(1); wedstrijd.ScoreUit += GetRandomScore(1); } } return(wedstrijd); }
public bool ValidateWedstrijd(Wedstrijd wedstrijd) { bool validated = true; Message.Clear(); if (wedstrijd.IsBezig || wedstrijd.IsGespeeld) { validated = false; Message.SetMessageHeader($"Wedstijd {wedstrijd.NaamToString} is al gespeeld"); } else { if (wedstrijd.ThuisTeam == null) { validated = false; Message.AddLineToMessageBody("Selecteer een thuisteam."); } if (wedstrijd.UitTeam == null) { validated = false; Message.AddLineToMessageBody("Selecteer een uitteam."); } if (wedstrijd.ThuisTeam?.Geslacht != wedstrijd.UitTeam?.Geslacht) { validated = false; Message.AddLineToMessageBody("U kunt alleen wedstrijden van teams met hetzelfde geslacht maken."); } if (wedstrijd.Datum < DateTimeOffset.Now) { validated = false; Message.AddLineToMessageBody("Selecteer een tijd in de toekomst."); } } return(validated); }
private void CreateGameSheet(int index) { try { Assembly _assembly; StreamReader objReader; //Read the complete file and replace the text _assembly = Assembly.GetExecutingAssembly(); //string[] rel = _assembly.GetManifestResourceNames(); objReader = new StreamReader(_assembly.GetManifestResourceStream("structures.Printing.gameSheet.html")); string content = objReader.ReadToEnd(); objReader.Close(); //Replace the text Wedstrijd w = _fileteredWedstrijdUurlist[index]; string home = w.Home.ToString(); content = content.Replace("[HOME]", home); string away = w.Away.ToString(); content = content.Replace("[AWAY]", away); string title = home + " - " + away; content = content.Replace("[TITLE]", title); string terrein = w.Terrein.ToString(); content = content.Replace("[TERREIN]", terrein); string scheidsrechter = w.Scheidsrechter.ToString(); content = content.Replace("[SCHEIDSRECHTER]", scheidsrechter); string reeks = w.ReeksNaam; content = content.Replace("[REEKS]", reeks); string uur = w.Aanvangsuur.ToShortTimeString(); content = content.Replace("[AANVANGSUUR]", uur); //Write content to new html-file StreamWriter writer = new StreamWriter(("gameSheet_adj.html")); writer.Write(content); writer.Close(); //Open HTML file Process.Start("gameSheet_adj.html"); } catch (Exception e) { throw e; } }
public ActionResult DeleteConfirmed(int id) { Wedstrijd wedstrijd = db.Wedstrijden.Find(id); db.Wedstrijden.Remove(wedstrijd); db.SaveChanges(); return(RedirectToAction("Index")); }
public IActionResult AddWedstrijd([FromBody] Wedstrijd wedstrijd) { _context.Wedstrijden.Add(wedstrijd); _context.SaveChanges(); return(Ok()); }
public void PasWedtrijdAan(Wedstrijd bestaandeWedstrijd, Wedstrijd currentWedstrijdCopy) { if (ValidateWedstrijd(currentWedstrijdCopy)) { _dataBaseRepository.PasWedstrijdAan(bestaandeWedstrijd, currentWedstrijdCopy); Message.SetMessageHeader($"Wedstijd {bestaandeWedstrijd.NaamToString} is aangepast"); } }
private void SimulatieButton_Click(object sender, EventArgs e) { Team teamHome = new Team(); Team teamOut = new Team(); var ButtonTag = ((Button)sender).Tag; ((Button)sender).Visible = false; MatchesPlayed++; // Check the Home team if (ButtonTag.ToString()[2] == 'A') { teamHome = Team_A; } else if (ButtonTag.ToString()[2] == 'B') { teamHome = Team_B; } else if (ButtonTag.ToString()[2] == 'C') { teamHome = Team_C; } else { teamHome = Team_D; } // Check the Out team if (ButtonTag.ToString()[3] == 'A') { teamOut = Team_A; } else if (ButtonTag.ToString()[3] == 'B') { teamOut = Team_B; } else if (ButtonTag.ToString()[3] == 'C') { teamOut = Team_C; } else { teamOut = Team_D; } // Start a match, write score to view, and check how many matches are played Wedstrijd wedstrijd = new Wedstrijd(teamHome, teamOut); // Add match to list of played matches Current_Poule.Wedstrijden.Add(wedstrijd); // Write score to labels Set_Score(wedstrijd.ThuisGoals, wedstrijd.UitGoals, ButtonTag); // Check amount of played matches if (MatchesPlayed == 6) { Check_PouleRank(); } }
public async System.Threading.Tasks.Task <ActionResult> Winkelmandje(WinkelmandViewModel vm) { IList <Winkelmandlijn> lines = new List <Winkelmandlijn>(); for (int i = 0; i < vm.winkelmandlineIDS.Count(); i++) { lines.Add(winkservice.getLineByID(vm.winkelmandlineIDS[i])); } for (int i = 0; i < lines.Count(); i++) { } Bestelling bestelling = new Bestelling(); bestelling.gebruikerID = User.Identity.GetUserId(); bestelling.date = DateTime.Today.Date; bestelling = bservice.Create(bestelling); IdentityMessage msg = new IdentityMessage(); msg.Subject = "Uw bestelling"; msg.Destination = gservice.getGebruikerByID(User.Identity.GetUserId()).email; string content = "<h4>Uw bestelling</h4><p>Hieronder vindt u een overzicht van uw bestelling:</p><table style='text-align:center;'><thead style='background:#333;color:#fff;'><tr><td>Type</td><td>Wedstrijd</td><td>Prijs</td><td>Plaats</td></tr></thead><tbody>"; for (int i = 0; i < lines.Count(); i++) { Bestellijn line = new Bestellijn(); if (lines.ElementAt(i).AboID == null) { line.ticketID = lines.ElementAt(i).TicketID; Ticket t = tservice.getTicketByID(line.ticketID.Value); Wedstrijd w = wservice.getWedstrijdByID(t.wedstrijdID); Ploeg thuis = plservice.getPloegByID(w.thuisID); Ploeg uit = plservice.getPloegByID(w.uitID); line.bestellingID = bestelling.BestellingID; Prijs p = prservice.getPriceByID(t.PrijsID); Plaats pl = pservice.getPlaatsByID(p.plaatsID); content += "<tr><td>Ticket</td><td>" + thuis.naam + " - " + uit.naam + "</td><td>" + p.prijs + ",00</td><td>" + pl.plaatsNaam + "</td></tr>"; } else { line.aboID = lines.ElementAt(i).AboID; Abo a = aservice.getAboByID(line.aboID.Value); line.bestellingID = bestelling.BestellingID; Plaats pl = pservice.getPlaatsByID(a.plaatsID); Ploeg ploeg = plservice.getPloegByID(a.ploegID); content += "<tr><td>Abonnement</td><td>" + ploeg.naam + "</td><td>" + a.prijs + ",00</td><td>" + pl.plaatsNaam + "</td></tr>"; } blservice.Create(line); } content += "</tbody></table>"; winkservice.DeleteLinesFromUser(User.Identity.GetUserId()); msg.Body = content; EmailService service = new EmailService(); await service.SendAsync(msg); return(RedirectToAction("OrderBevestiging", "Home")); }
async private Task BeeindigWedstrijd(Wedstrijd currentWedstrijd) { Message.SetMessageBody(string.Empty); Message.SetMessageHeader($"De eindstand van wedstrijd {currentWedstrijd.NaamToString} is {currentWedstrijd.Uitslag}."); await Task.Delay(2000); Message.SetMessageHeader(string.Empty); //wedstrijdCopy.UitTeam.Wedstrijden.Add(wedstrijdCopy); //wedstrijdCopy.ThuisTeam.Wedstrijden.Add(wedstrijdCopy); }
private void SimuleerWedstrijden(List <Wedstrijd> wedstrijden) { foreach (var wedstrijd in wedstrijden) { Wedstrijd gesimuleerdeWedstrijd = SimuleerWedstrijd(wedstrijd); _context.Update(gesimuleerdeWedstrijd); } _context.SaveChanges(); }
public IActionResult DeleteWedstrijd(int id) { Wedstrijd w = _wedstrijdRepository.GetById(id); if (w == null) { return(NotFound()); } ViewData["Datum"] = w.DatumGespeeld; return(View()); }
public ActionResult Edit([Bind(Include = "Id,Plaats,Datum,Stayer,AfstandId,SportId")] Wedstrijd wedstrijd) { if (ModelState.IsValid) { db.Entry(wedstrijd).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.AfstandId = new SelectList(db.Afstanden, "Id", "Lengte", wedstrijd.AfstandId); ViewBag.SportId = new SelectList(db.Sporten, "Id", "soortSport", wedstrijd.SportId); return(View(wedstrijd)); }
internal void VulInFinales() { Wedstrijd troostFinale = GetWedstrijdForKnockoutId(4).SingleOrDefault(); Wedstrijd finale = GetWedstrijdForKnockoutId(5).SingleOrDefault(); List <Wedstrijd> halveFinales = GetWedstrijdForKnockoutId(3); finale.TeamThuis = halveFinales[0].Winnaar; finale.TeamUit = halveFinales[1].Winnaar; troostFinale.TeamThuis = halveFinales[0].Verliezer; troostFinale.TeamUit = halveFinales[1].Verliezer; }
public ActionResult AddWedstrijd(WedstrijdViewModel WVM) { if (ModelState.IsValid) { var wedstrijd = new Wedstrijd(); wedstrijd.Datum = WVM.Datum; wedstrijd.Plaats = WVM.Plaats; wedstrijd.Stayer = WVM.Stayer; wedstrijd.AfstandId = int.Parse(WVM.Afstand); wedstrijd.SportId = int.Parse(WVM.Sport); var putter = db.Putters.FirstOrDefault(p => p.Id == WVM.PutterId); var wed = db.Wedstrijden.Include("Deelnemers").FirstOrDefault(w => w.Datum == wedstrijd.Datum && w.Plaats == wedstrijd.Plaats && w.SportId == wedstrijd.SportId && w.AfstandId == wedstrijd.AfstandId && w.Stayer == wedstrijd.Stayer); if (wed == null) { db.Wedstrijden.Add(wedstrijd); putter.Wedstrijden.Add(wedstrijd); } else { putter.Wedstrijden.Add(wed); } db.SaveChanges(); return(RedirectToAction("Index", "Wedstrijden", new { Id = WVM.PutterId })); } else { ViewBag.Afstand = new SelectList(db.Afstanden, "Id", "Lengte"); ViewBag.Sport = new SelectList(db.Sporten, "Id", "soortSport"); var plaatsen = from wedstrijd in db.Wedstrijden orderby wedstrijd.Plaats select wedstrijd.Plaats; var locaties = plaatsen.Distinct(); var selectlistLocaties = locaties.Select (x => new SelectListItem() { Value = x, Text = x }).ToList(); //ViewBag.Plaats = new SelectList(selectlistLocaties ,"Value","Text"); ViewBag.Plaats = selectlistLocaties; return(PartialView("_AddWedstrijd", WVM)); } }
async public Task SpeelWedstrijdAsync(Wedstrijd currentWedstrijd) { await StartWedstrijdAsync(currentWedstrijd); Message.SetMessageHeader(FeedbackMessages.GetWedstrijdWordtGespeeld(currentWedstrijd)); await SimuleerAanvallenAsync(currentWedstrijd); //return await BeeindigWedstrijd(currentWedstrijd); //return t; }
public ActionResult Wedstrijd(WedstrijdViewModel vm) { double totalTickets = 0; for (int i = 0; i < vm.numberOfTickets.Count(); i++) { totalTickets += vm.numberOfTickets[i]; } int aantalTicketsInWinkelmandje = winkservice.countTickets(winkservice.getLinesFromUser(User.Identity.GetUserId())); if (totalTickets + aantalTicketsInWinkelmandje > 10) { return(Json(new { success = false, message = "Je kan maximum 10 tickets per keer kopen. Pas je bestelling aan" })); } else { Wedstrijd Wedstrijd = wservice.getWedstrijdByID(vm.WedstrijdID); if (DateTime.Today.AddMonths(1) > Wedstrijd.date)//zorgt ervoor dat je niet meer dan een maand op voorhand kan bestellen { List <Plaats> plaatsen = pservice.All().ToList(); List <Prijs> prijzen = prservice.getPricesByStadion(Wedstrijd.stadionID).ToList(); if (placeLeft(vm.numberOfTickets, Wedstrijd) == "Volgende plaatsen zijn uitverkocht: ") { for (int i = 0; i < plaatsen.Count(); i++) { for (int j = 0; j < vm.numberOfTickets[i]; j++) { Ticket ticket = new Ticket(); ticket.wedstrijdID = Wedstrijd.wedstrijdID; ticket.PrijsID = prijzen.ElementAt(i).prijsID; ticket = tservice.Add(ticket); Winkelmandlijn wml = new Winkelmandlijn(); wml.gebruikerID = User.Identity.GetUserId(); wml.TicketID = ticket.ticketID; winkservice.AddLine(wml); } } return(Json(new { success = true })); } else { return(Json(new { success = false, message = placeLeft(vm.numberOfTickets, Wedstrijd) })); } } else { return(Json(new { success = false, message = "Je kan ten minste een maand op voorhand tickets bestellen." })); } } }
// GET: Admin/Wedstrijds/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Wedstrijd wedstrijd = db.Wedstrijden.Find(id); if (wedstrijd == null) { return(HttpNotFound()); } return(View(wedstrijd)); }
private decimal BepaalPrijs(Vak vak, int wedstrijdId) { // prijs wordt bepaald door vaktype en club VakType vakType = VakTypeDAO.FindVakType(vak.VakTypeid); decimal standaardPrijs = vakType.standaardPrijs; // null-coalescing operator -> It returns the left-hand operand if the operand is not null; otherwise it returns the right hand operand. // Want bool is nullable... TODO eventueel Nullable afzetten, dan komen we dit probleem niet tegen. Wedstrijd wedstrijd = wedstrijdDAO.getWedstrijdById(wedstrijdId); // 'Club' is altijd de thuisploeg decimal coefficient = wedstrijd.Club.ticketPrijsCoefficient; return(standaardPrijs * coefficient); }
// GET: Admin/Wedstrijds/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Wedstrijd wedstrijd = db.Wedstrijden.Find(id); if (wedstrijd == null) { return(HttpNotFound()); } ViewBag.AfstandId = new SelectList(db.Afstanden, "Id", "Lengte", wedstrijd.AfstandId); ViewBag.SportId = new SelectList(db.Sporten, "Id", "soortSport", wedstrijd.SportId); return(View(wedstrijd)); }
public static void BerekenPunten(Tuple <int, int> Score, Wedstrijd wedstrijd) { if (Score.Item1 == Score.Item2) { wedstrijd.ThuisTeam.TotaalPunten += 1; wedstrijd.UitTeam.TotaalPunten += 1; } else if (Score.Item1 > Score.Item2) { wedstrijd.ThuisTeam.TotaalPunten += 3; } else if (Score.Item1 < Score.Item2) { wedstrijd.UitTeam.TotaalPunten += 3; } }
public IActionResult WijzigWedstrijd(Wedstrijd wedstrijd) { if (ModelState.IsValid) { try { _context.Update(wedstrijd); _context.SaveChanges(); } catch (DbUpdateConcurrencyException) { throw; } return(RedirectToAction("Index")); } return(View(wedstrijd)); }
public IActionResult DeleteWedstrijdConfirmed(int id) { Wedstrijd wedstrijd = null; try { wedstrijd = _wedstrijdRepository.GetById(id); _wedstrijdRepository.Remove(wedstrijd); _spelerRepository.SaveChanges(); TempData["message"] = $"De wedstrijd van {wedstrijd.DatumGespeeld} werd succesvol verwijderd!"; } catch { TempData["error"] = $"Er ging iets verkeerd, de wedstrijd van {wedstrijd.DatumGespeeld} werd niet verwijderd"; } return(RedirectToAction(nameof(Index))); }
public IActionResult UpdateWedstrijd([FromRoute] int id, [FromBody] Wedstrijd wedstrijd) { var wedstrijdToUpdate = _context.Wedstrijden.Find(id); if (wedstrijdToUpdate == null) { return(NotFound("Wedstrijd met id '" + id + "' niet gevonden.")); } wedstrijdToUpdate.updateWedstrijd(wedstrijd); /*if (false) * return BadRequest("Wedstrijd met id...");*/ _context.SaveChanges(); return(Ok()); }