public void LoadPreMatchEvaluation(Inti_Match match, IntiDataContext db) { //get a list of athletes represented in teams, sorted by total scores var highestScoringHomeAthletes = GetAthletesForClub(match.HomeClub, db); var highestScoringAwayAthletes = GetAthletesForClub(match.AwayClub, db); LoadStakeholders(highestScoringHomeAthletes.Union(highestScoringAwayAthletes).ToList(), db); lblHeader.Text = "Lag med intressen"; }
protected void btnAddMatch_Click(object sender, EventArgs e) { using(var db = Global.GetConnection()) { var match = new Inti_Match(); match.HomeClub = new Guid(drpAddMatchHomeTeam.SelectedValue); match.AwayClub = new Guid(drpAddMatchAwayTeam.SelectedValue); match.TournamentGUID = TourId; match.MatchDate = DateTime.Parse(txtAddMatchMatchDate.Text); match.TourDay = int.Parse(drpAddMatchTourDay.SelectedValue); match.IsUpdated = false; db.Inti_Match.InsertOnSubmit(match); db.SubmitChanges(); } LoadMatches(); }
protected void btnSave_Click(object sender, EventArgs e) { //get clubs using (var db = Global.GetConnection()) { var clubs = db.Inti_Club.Where(c => c.TournamentGUID == TourId).ToList(); var day = int.Parse(drpDay.SelectedValue); var matchDate = DateTime.Parse(txtDate.Text); var matches = txtMatches.Text; var rejectedEntries = String.Empty; var approvedEntries = String.Empty; var matchArray = matches.Split(new string[] {"\n"}, StringSplitOptions.RemoveEmptyEntries); foreach (var match in matchArray) { var matchClubs = match.Split(new string[] {"-", " "}, StringSplitOptions.RemoveEmptyEntries); //måste vara ett hemma och ett bortalag if (matchClubs.GetUpperBound(0) != 1) { rejectedEntries += HtmlLineBreak + match + " (fel antal lag)"; continue; } var homeTeamShort = matchClubs[0].Trim().ToUpper(); var awayTeamShort = matchClubs[1].Trim().ToUpper(); if (homeTeamShort == awayTeamShort) { rejectedEntries += HtmlLineBreak + match + " (hemmalag får inte vara samma som bortalag)"; continue; } //hemmalag måste finnas var homeClub = clubs.SingleOrDefault(c => c.ShortName == homeTeamShort); if (homeClub == null) { rejectedEntries += HtmlLineBreak + match + " (hittar inte hemmalaget)"; continue; } //bortalag måste finnas var awayClub = clubs.SingleOrDefault(c => c.ShortName == awayTeamShort); if (awayClub == null) { rejectedEntries += HtmlLineBreak + match + " (hittar inte bortalaget)"; continue; } //finns matchen? var dbMatch = db.Inti_Match.SingleOrDefault( m => m.TournamentGUID == TourId && m.HomeClub == homeClub.GUID && m.AwayClub == awayClub.GUID); approvedEntries += HtmlLineBreak + match; var isNew = false; if (dbMatch == null) { isNew = true; //create new match dbMatch = new Inti_Match(); dbMatch.HomeClub = homeClub.GUID; dbMatch.AwayClub = awayClub.GUID; dbMatch.TournamentGUID = TourId; approvedEntries += " (la till ny match)"; } else { approvedEntries += " (ändrade befintlig match)"; } dbMatch.TourDay = day; dbMatch.MatchDate = matchDate; if (isNew) db.Inti_Match.InsertOnSubmit(dbMatch); db.SubmitChanges(); } lblOutput.Text = (approvedEntries + HtmlLineBreak + rejectedEntries); } }
partial void DeleteInti_Match(Inti_Match instance);
partial void UpdateInti_Match(Inti_Match instance);
partial void InsertInti_Match(Inti_Match instance);
private void detach_Inti_Match(Inti_Match entity) { this.SendPropertyChanging(); entity.Inti_Tournament = null; }
private void detach_Inti_Match_HomeClub(Inti_Match entity) { this.SendPropertyChanging(); entity.HomeClubInti_Club = null; }
private void attach_Inti_Match(Inti_Match entity) { this.SendPropertyChanging(); entity.Inti_Club = this; }
public MatchDTO(Inti_Match match) { GUID = match.GUID; MatchLabel = match.HomeClubInti_Club.ShortName + " - " + match.Inti_Club.ShortName; if (match.IsUpdated ?? false) MatchLabel += " (" + match.HomeScore + "-" + match.AwayScore + ")"; if (match.MatchDate.HasValue) MatchLabel += " " + match.MatchDate.Value.ToShortDateString(); }
private void AddMatchPointEvent(IntiDataContext db, Inti_Match match, Inti_AthleteClub athleteClub, Inti_PointEvent pointEvent, int nmbrOfEvents) { for(var i=1;i<= nmbrOfEvents;i++) { var mpe = new Inti_MatchPointEvent(); mpe.MatchGUID = match.GUID; mpe.AthleteClubGUID = athleteClub.GUID; mpe.PointEventGUID = pointEvent.GUID; mpe.Points = pointEvent.Inti_PointEventPosition.Where( pep => pep.PositionGUID == athleteClub.PositionGUID).ToList()[0].Points; if (match.TourDay == 19 || match.TourDay == 38) { //dubbla poäng mpe.Points = mpe.Points * 2; } db.Inti_MatchPointEvent.InsertOnSubmit(mpe); } }
private string GetPointEventText(Inti_Match match) { var goalScorers = new List<string>(4); var redCarders = new List<string>(4); var ownGoalers = new List<string>(4); var pointEventsText = "<ul>"; foreach (var matchPointEvent in match.Inti_MatchPointEvent.OrderBy(mpe => mpe.Inti_PointEvent.Name).ThenBy(mpe => mpe.Inti_AthleteClub.AthleteGUID).ThenBy(mpe => mpe.Inti_AthleteClub.Inti_Club.Name).ToList()) { //get athletes name var athleteName = String.Format("{0} {1}", matchPointEvent.Inti_AthleteClub.Inti_Athlete.FirstName, matchPointEvent.Inti_AthleteClub.Inti_Athlete.LastName).Trim(); pointEventsText += String.Format("<li>{0} ({1}), {2}</li>", String.Format("<a href='/Player/{0}'>{1}</a>", matchPointEvent.Inti_AthleteClub.GUID, athleteName), matchPointEvent.Inti_AthleteClub.Inti_Club.ShortName, matchPointEvent.Inti_PointEvent.Name); //get info for match summary switch (matchPointEvent.Inti_PointEvent.Name.ToLower()) { case "mål": case "straffmål": if (!goalScorers.Contains(athleteName)) goalScorers.Add(athleteName); break; case "rött kort": if (!redCarders.Contains(athleteName)) redCarders.Add(athleteName); break; case "självmål": if (!ownGoalers.Contains(athleteName)) ownGoalers.Add(athleteName); break; } } //while we're at it - set the goal scorers etc in the match summary if (goalScorers.Count > 0) { MatchSummary += ConcatinateAthletes(goalScorers, "Målgörare"); } if (redCarders.Count > 0) { MatchSummary += ConcatinateAthletes(redCarders, "Utvisade"); } if (ownGoalers.Count > 0) { MatchSummary += ConcatinateAthletes(ownGoalers, "Självmål"); } pointEventsText += "</ul>"; return pointEventsText; }
protected void btnGenerateMatches_Click(object sender, EventArgs e) { using (var db = Global.GetConnection()) { //delete any matches fropm before, if any have been updated. Skip this action var checkUpdatedMatches = from m in db.Inti_Match where m.TournamentGUID == TourId select m; if (checkUpdatedMatches.ToList().Count > 0) { lblMatchEditMessage.Text = "Det finns redan matcher i denna tävlingen. Du får editera matcherna manuellt."; return; } //delete all matches in this tournament //var matchesToDelete = db.Inti_Match.Where(m => m.TournamentGUID == TourId); //foreach(var match in matchesToDelete.ToList()) //{ // db.Inti_Match.DeleteOnSubmit(match); //} //db.SubmitChanges(); //loop the clubs of the tournament var clubs = db.Inti_Club.Where(c => c.TournamentGUID == TourId); var clubs1 = clubs.ToList(); var clubs2 = clubs.ToList(); foreach(var homeClub in clubs1) { foreach(var awayClub in clubs2) { if (homeClub.GUID != awayClub.GUID) { var match = new Inti_Match(); match.TournamentGUID = TourId; match.HomeClub = homeClub.GUID; match.AwayClub = awayClub.GUID; match.MatchDate = DateTime.Parse(EndRegistration.Text); match.TourDay = 1; match.IsUpdated = false; db.Inti_Match.InsertOnSubmit(match); } } } db.SubmitChanges(); } }