LongoMatch.Core.Store.ProjectLongoMatch.SubsitutePlayer C# (CSharp) Method

SubsitutePlayer() public method

public SubsitutePlayer ( SportsTeam team, PlayerLongoMatch playerIn, PlayerLongoMatch playerOut, SubstitutionReason reason, Time subsTime ) : SubstitutionEvent
team SportsTeam
playerIn PlayerLongoMatch
playerOut PlayerLongoMatch
reason SubstitutionReason
subsTime Time
return SubstitutionEvent
        public SubstitutionEvent SubsitutePlayer(SportsTeam team, PlayerLongoMatch playerIn, PlayerLongoMatch playerOut,
		                                          SubstitutionReason reason, Time subsTime)
        {
            LineupEvent lineup;
            SubstitutionEvent se;

            lineup = Timeline.OfType<LineupEvent> ().FirstOrDefault ();
            if (lineup == null) {
                throw new SubstitutionException (Catalog.GetString ("No lineup events found"));
            }
            if (subsTime < lineup.EventTime) {
                throw new SubstitutionException (Catalog.GetString ("A substitution can't happen before the lineup event"));
            }
            se = new SubstitutionEvent ();
            se.EventType = SubstitutionsEventType;
            se.In = playerIn;
            se.Out = playerOut;
            se.Reason = reason;
            se.EventTime = subsTime;
            se.Teams.Add (team);
            Timeline.Add (se);
            return se;
        }