protected void rptEvents_ItemDataBound(object sender, RepeaterItemEventArgs e) { MatchEventDTO ev = e.Item.DataItem as MatchEventDTO; MatchLineupDTO lineup = DataItem.Lineup.FirstOrDefault(l => l.Player_Id == ev.Player1_Id); if (lineup != null) { MatchEvent meControl = null; Label lblPlayerName = null; bool isOwnGoal = ev.Event_Cd == Constants.DB.EventTypeCodes.Goal && ((ev.EventFlags & Constants.DB.EventFlags.OwnGoal) > 0); if ((lineup.IsHomeTeamPlayer && !isOwnGoal) || (!lineup.IsHomeTeamPlayer && isOwnGoal)) { meControl = e.Item.FindControl("meHome") as MatchEvent; lblPlayerName = e.Item.FindControl("lblHomeEvent") as Label; } else { meControl = e.Item.FindControl("meAway") as MatchEvent; lblPlayerName = e.Item.FindControl("lblAwayEvent") as Label; } meControl.Visible = true; meControl.EventType_CD = ev.Event_Cd; meControl.Minute = ev.Minute; meControl.EventFlags = ev.EventFlags; meControl.Player1 = ev.Player1; meControl.Player2 = ev.Player2; lblPlayerName.Text = FormatName(lineup.Player_FirstName, lineup.Player_LastName, lineup.Player_DisplayName, lineup.Player_CountryId) + ", " + ev.Minute.ToString(); } }
protected void rptEvents_ItemDataBound(object sender, RepeaterItemEventArgs e) { MatchEventDTO ev = e.Item.DataItem as MatchEventDTO; DropDownList ddlEventTypeCd = e.Item.FindControl("ddlEventTypeCd") as DropDownList; CheckBoxList cblEvents = e.Item.FindControl("cblEventFlags") as CheckBoxList; if (ev != null && ddlEventTypeCd != null && cblEvents != null && ev.Event_Cd != null) { if (ev.Event_Cd != Constants.UI.DropdownDefaultValue) { ddlEventTypeCd.SelectedValue = ev.Event_Cd; cblEvents.DataSource = UIHelper.EventCodeEventFlagsMap[ev.Event_Cd]; cblEvents.DataTextField = "Value"; cblEvents.DataValueField = "Key"; cblEvents.DataBind(); if (ev.EventFlags.HasValue) { foreach (ListItem li in cblEvents.Items) { int flag = int.Parse(li.Value); li.Selected = (ev.EventFlags.Value & flag) > 0; } } } } }
protected void rptEvents_ItemDataBound(object sender, RepeaterItemEventArgs e) { MatchEventDTO ev = e.Item.DataItem as MatchEventDTO; MatchEvent meControl = e.Item.FindControl("me") as MatchEvent; meControl.Player1 = ev.Player1; meControl.Player2 = ev.Player2; }
private void UpdateTeamUnCompletedPassesEvent(MatchEvents matchEvent, MatchEventDTO TeamEvent, List <PlayerDTO> players) { TeamEvent.UnCompletedPasses++; var player = players.Where(p => p.PlayerID == matchEvent.PlayerID_1).SingleOrDefault(); if (player != null) { player.PlayerEvents.UnCompletedPasses++; } }
private void UpdateTeamShotOffTargetEvent(MatchEvents matchEvent, MatchEventDTO TeamEvent, List <PlayerDTO> players) { TeamEvent.ShotsOffTarget++; var player = players.Where(p => p.PlayerID == matchEvent.PlayerID_1).SingleOrDefault(); if (player != null) { player.PlayerEvents.ShotsOffTarget++; } }
private void UpdateTeamOwnGoalEvent(MatchEvents matchEvent, MatchEventDTO TeamEvent, List <PlayerDTO> players) { TeamEvent.OwnGoals++; var player = players.Where(p => p.PlayerID == matchEvent.PlayerID_1).SingleOrDefault(); if (player != null) { player.PlayerEvents.OwnGoals++; } }
public async Task <IActionResult> CreateEntity([FromBody] MatchEventDTO matchEventDTO) { try { MatchEventDTO createdMatchEvent = await _matchEventService.CreateEntity(matchEventDTO); return(Ok(createdMatchEvent)); } catch (Exception e) { Console.WriteLine(e.Message); return(BadRequest(e.Message)); } }
public async Task <IActionResult> GetEntityById(int matchId, int matchEventId) { try { MatchEventDTO matchEvent = await _matchEventService.GetEntityById(matchId, matchEventId); return(Ok(matchEvent)); } catch (Exception e) { Console.WriteLine(e.Message); return(BadRequest(e.Message)); } }
protected void rptLineup_ItemDataBound(object sender, RepeaterItemEventArgs e) { Pair l = e.Item.DataItem as Pair; MatchLineupDTO hp = l.First as MatchLineupDTO; MatchLineupDTO ap = l.Second as MatchLineupDTO; Label lblHPlayerNum = e.Item.FindControl("lblHPlayerNum") as Label; lblHPlayerNum.Text = hp.ShirtNum.HasValue & hp.ShirtNum > 0 ? hp.ShirtNum.Value.ToString() : string.Empty; Label lblAPlayerNum = e.Item.FindControl("lblAPlayerNum") as Label; lblAPlayerNum.Text = ap.ShirtNum.HasValue & ap.ShirtNum > 0 ? ap.ShirtNum.Value.ToString() : string.Empty; Panel pHomePlayer = e.Item.FindControl("pHomePlayer") as Panel; HyperLink aHomePlayer = pHomePlayer.FindControl("aHomePlayer") as HyperLink; FormatPlayerHyperLink(aHomePlayer, hp); MatchEventDTO hPlayerSubstEvent = DataItem.Events.FirstOrDefault(ev => ev.Player1_Id == hp.Player_Id && ev.Event_Cd == Constants.DB.EventTypeCodes.Substitution); if (hPlayerSubstEvent != null) { Panel pHomePlayerSubs = e.Item.FindControl("pHomePlayerSubst") as Panel; pHomePlayerSubs.Visible = true; HyperLink aHomePlayerSubst = pHomePlayerSubs.FindControl("aHomePlayerSubst") as HyperLink; FormatPlayerSubstHyperLink(aHomePlayerSubst, hPlayerSubstEvent); } Panel pAwayPlayer = e.Item.FindControl("pAwayPlayer") as Panel; HyperLink aAwayPlayer = pHomePlayer.FindControl("aAwayPlayer") as HyperLink; FormatPlayerHyperLink(aAwayPlayer, ap); MatchEventDTO aPlayerSubstEvent = DataItem.Events.FirstOrDefault(ev => ev.Player1_Id == ap.Player_Id && ev.Event_Cd == Constants.DB.EventTypeCodes.Substitution); if (aPlayerSubstEvent != null) { Panel pAwayPlayerSubs = e.Item.FindControl("pAwayPlayerSubst") as Panel; pAwayPlayerSubs.Visible = true; HyperLink aAwayPlayerSubst = pAwayPlayerSubs.FindControl("aAwayPlayerSubst") as HyperLink; FormatPlayerSubstHyperLink(aAwayPlayerSubst, aPlayerSubstEvent); } if (e.Item.ItemIndex == 10) { HtmlTableRow trRow = e.Item.FindControl("trPlayerRow") as HtmlTableRow; trRow.Attributes.Add("class", "trSub2"); } }
public ActionResult <MatchEventDTO> GetMatchEvent(int matchEventId) { MatchEventDTO result = new MatchEventDTO(); using (UaFootballContext db = new UaFootballContext()) { MatchEvents me = new MatchEvents(); var o = (from matchEvent in db.MatchEvents where matchEvent.MatchEventId == matchEventId select new { A = matchEvent, B = matchEvent.Player1, C = matchEvent.Player2 }).Single(); me = o.A; me.Player1 = o.B; me.Player2 = o.C; if (me != null) { result = new MatchEventDTO { EventFlags = me.EventFlags, Event_Cd = me.EventCd, MatchEvent_Id = me.MatchEventId, Match_Id = me.MatchId, Minute = me.Minute, Player1_Id = me.Player1Id, Player2_Id = me.Player2Id, Player1 = new PlayerDTO { First_Name = me.Player1.FirstName, Last_Name = me.Player1.LastName, Display_Name = me.Player1.DisplayName, Country_Id = me.Player1.CountryId } }; } if (me.Player2Id.HasValue) { result.Player2 = new PlayerDTO { First_Name = me.Player2.FirstName, Last_Name = me.Player2.LastName, Display_Name = me.Player2.DisplayName, Country_Id = me.Player2.CountryId }; } } return(result); }
public async Task <IActionResult> UpdateEntity([FromBody] MatchEventDTO matchEventDTO, int matchId, int matchEventId) { try { if (matchEventDTO.Id != matchId) { throw new InvalidOperationException("Passed model id is not equal to request URL id."); } await _matchEventService.UpdateEntity(matchEventDTO, matchId, matchEventId); return(Ok(matchEventDTO)); } catch (Exception e) { Console.WriteLine(e.Message); return(BadRequest(e.Message)); } }
protected override MatchDTO UIToDTO() { bool isNationalTeamMatch = cbMatchKind.Checked; int? homeTeamId = actbHomeTeam.Value.ParseInt(false); int? awayTeamId = actbAwayTeam.Value.ParseInt(false); short? homePenScore = tbHomeTeamPenaltyScore.Text.Length > 0 ? (short?)short.Parse(tbHomeTeamPenaltyScore.Text) : null; short? awayPenScore = tbAwayTeamPenaltyScore.Text.Length > 0 ? (short?)short.Parse(tbAwayTeamPenaltyScore.Text) : null; int? refereeId = actbReferee.Value.ParseInt(true); MatchDTO MatchToSave = new MatchDTO { HomeClub_Id = isNationalTeamMatch ? null : homeTeamId, HomeNationalTeam_Id = isNationalTeamMatch ? homeTeamId : null, AwayClub_Id = isNationalTeamMatch ? null : awayTeamId, AwayNationalTeam_Id = isNationalTeamMatch ? awayTeamId : null, HomeScore = short.Parse(tbHomeTeamScore.Text), AwayScore = short.Parse(tbAwayTeamScore.Text), HomePenaltyScore = homePenScore, AwayPenaltyScore = awayPenScore, Competition_Id = GetDropdownValue(ddlCompetitions).Value, Season_Id = GetDropdownValue(ddlSeasons).Value, Stadium = new StadiumDTO { Stadium_ID = GetDropdownValue(ddlStadiums).Value }, CompetitionStage_Id = ddlStage.SelectedValue.ParseInt(true), Match_Id = DataItem.Match_Id, Spectators = tbSpecatators.Text.ParseInt(false), Referee = refereeId == null ? null : new RefereeDTO { Referee_Id = refereeId.Value }, Lineup = new List <MatchLineupDTO>(), Events = new List <MatchEventDTO>(), SpecialNote = tbSpecialNotes.Text.Length > 0 ? tbSpecialNotes.Text : null, AdminNotes = string.IsNullOrWhiteSpace(tbAdminNotes.Text) ? null : tbAdminNotes.Text, Sources = string.IsNullOrWhiteSpace(tbSources.Text) ? null : tbSources.Text }; DateTime date = DateTime.Now; if (DateTime.TryParse(tbDate.Text, out date)) { MatchToSave.Date = date; } int matchFlag = 0; foreach (ListItem li in cblMatchFlags.Items) { if (li.Selected) { int flag = int.Parse(li.Value); matchFlag |= flag; } } MatchToSave.Flags = matchFlag; int homeCountryId = GetCountryId(isNationalTeamMatch, homeTeamId); int awayCountryId = GetCountryId(isNationalTeamMatch, awayTeamId); foreach (RepeaterItem ri in rptLineup.Items) { AutocompleteTextBox actbHomePlayer = ri.FindControl("actbHomePlayer") as AutocompleteTextBox; AutocompleteTextBox actbAwayPlayer = ri.FindControl("actbAwayPlayer") as AutocompleteTextBox; TextBox tbHomePlayerShirtNumber = ri.FindControl("tbHomePlayerShirtNumber") as TextBox; TextBox tbAwayPlayerShirtNumber = ri.FindControl("tbAwayPlayerShirtNumber") as TextBox; HiddenField hfHomePlayerLineupId = ri.FindControl("hfHomePlayerLineupId") as HiddenField; HiddenField hfAwayPlayerLineupId = ri.FindControl("hfAwayPlayerLineupId") as HiddenField; CheckBox cbHGoalkeeper = ri.FindControl("cbHGoalkeeper") as CheckBox; CheckBox cbAGoalkeeper = ri.FindControl("cbAGoalkeeper") as CheckBox; CheckBox cbHCaptain = ri.FindControl("cbHCaptain") as CheckBox; CheckBox cbACaptain = ri.FindControl("cbACaptain") as CheckBox; CheckBox cbHDebut = ri.FindControl("cbHDebut") as CheckBox; CheckBox cbADebut = ri.FindControl("cbADebut") as CheckBox; if (actbHomePlayer.Text.Length > 0 && tbHomePlayerShirtNumber.Text.Length > 0) { int hLineupFlag = 0 | (cbHGoalkeeper.Checked ? Constants.DB.LineupFlags.Goalkeeper : 0) | (cbHCaptain.Checked ? Constants.DB.LineupFlags.Captain : 0) | (cbHDebut.Checked ? Constants.DB.LineupFlags.Debut : 0); MatchLineupDTO hpml = GetLineup(actbHomePlayer, homeCountryId, int.Parse(tbHomePlayerShirtNumber.Text), int.Parse(hfHomePlayerLineupId.Value), ri.ItemIndex > 10, true, hLineupFlag); MatchToSave.Lineup.Add(hpml); } if (actbAwayPlayer.Text.Length > 0 && tbAwayPlayerShirtNumber.Text.Length > 0) { int aLineupFlag = 0 | (cbAGoalkeeper.Checked ? Constants.DB.LineupFlags.Goalkeeper : 0) | (cbACaptain.Checked ? Constants.DB.LineupFlags.Captain : 0) | (cbADebut.Checked ? Constants.DB.LineupFlags.Debut : 0); MatchLineupDTO apml = GetLineup(actbAwayPlayer, awayCountryId, int.Parse(tbAwayPlayerShirtNumber.Text), int.Parse(hfAwayPlayerLineupId.Value), ri.ItemIndex > 10, false, aLineupFlag); MatchToSave.Lineup.Add(apml); } } if (!string.IsNullOrEmpty(actbHomeCoach.Value) && !string.IsNullOrEmpty(actbHomeCoach.Text)) { MatchLineupDTO homeCoachLineupDTO = new MatchLineupDTO { IsHomeTeamPlayer = true, Match_Id = DataItem.Match_Id, IsSubstitute = false, CoachId = int.Parse(actbHomeCoach.Value), ShirtNum = null, MatchLineup_Id = string.IsNullOrEmpty(hfHomeCoachLineupId.Value) ? 0 : int.Parse(hfHomeCoachLineupId.Value), Flags = cbHomeCoachInCharge.Checked ? Constants.DB.LineupFlags.CoachInCharge : 0 }; MatchToSave.Lineup.Add(homeCoachLineupDTO); } if (!string.IsNullOrEmpty(actbAwayCoach.Value) && !string.IsNullOrEmpty(actbAwayCoach.Text)) { MatchLineupDTO awayCoachLineupDTO = new MatchLineupDTO { IsHomeTeamPlayer = false, Match_Id = DataItem.Match_Id, IsSubstitute = false, CoachId = int.Parse(actbAwayCoach.Value), ShirtNum = null, MatchLineup_Id = string.IsNullOrEmpty(hfAwayCoachLineupId.Value) ? 0 : int.Parse(hfAwayCoachLineupId.Value), Flags = cbAwayCoachInCharge.Checked ? Constants.DB.LineupFlags.CoachInCharge : 0 }; MatchToSave.Lineup.Add(awayCoachLineupDTO); } foreach (RepeaterItem ri in rptEvents.Items) { TextBox tbMinute = ri.FindControl("tbMinute") as TextBox; HiddenField hfEventId = ri.FindControl("hfMatchEventId") as HiddenField; DropDownList ddlEventType = ri.FindControl("ddlEventTypeCd") as DropDownList; AutocompleteTextBox actbPlayer1 = ri.FindControl("actbEventPlayer1") as AutocompleteTextBox; AutocompleteTextBox actbPlayer2 = ri.FindControl("actbEventPlayer2") as AutocompleteTextBox; CheckBoxList cblEventFlags = ri.FindControl("cblEventFlags") as CheckBoxList; bool isValid = tbMinute.Text.Length > 0 && actbPlayer1.Value.Length > 0; if (ddlEventType.SelectedValue == Constants.DB.EventTypeCodes.Substitution) { isValid &= actbPlayer2.Value.Length > 0; } if (isValid) { MatchEventDTO newEvent = new MatchEventDTO { Event_Cd = ddlEventType.SelectedValue, MatchEvent_Id = hfEventId.Value.Length > 0 ? int.Parse(hfEventId.Value) : 0, Minute = int.Parse(tbMinute.Text), Player1_Id = int.Parse(actbPlayer1.Value), Player2_Id = actbPlayer2.Value.Length > 0 ? (int?)int.Parse(actbPlayer2.Value) : null, Match_Id = DataItem.Match_Id }; if (newEvent.Player1_Id > 0) { int eventFlags = 0; foreach (ListItem item in cblEventFlags.Items) { if (item.Selected) { eventFlags |= int.Parse(item.Value); } } newEvent.EventFlags = eventFlags; MatchToSave.Events.Add(newEvent); } } } foreach (string noteCodeDropdownId in Request.Form.AllKeys.Where(k => k.StartsWith("matchNoteCode_"))) { MatchNoteDTO newNote = new MatchNoteDTO { Code = Request.Form[noteCodeDropdownId], Text = Request.Form[noteCodeDropdownId.Replace("Code", "Text")] }; if (!string.IsNullOrEmpty(newNote.Text)) { MatchToSave.Notes.Add(newNote); } } return(MatchToSave); }
protected void FormatPlayerSubstHyperLink(HyperLink h, MatchEventDTO me) { h.Text = FormatName(me.Player2.First_Name, me.Player2.Last_Name, me.Player2.Display_Name, me.Player2.Country_Id) + ", " + me.Minute.ToString(); h.NavigateUrl = string.Format("Player.aspx?{0}={1}", Constants.QueryParam.PlayerId, me.Player2_Id); }