private void ShootingRangeOnBestShot(object sender, ShotEventArgs e)
 {
     if (_sessionsOngoing.ContainsKey(e.LaneNumber))
     {
         SubSession currentSubSession = _sessionsOngoing[e.LaneNumber].CurrentSubsession();
         Shot shot =
             _shotDataStore.FindBySubSessionId(currentSubSession.SessionSubtotalId)
                 .Single(_ => _.Ordinal == e.Ordinal);
         currentSubSession.BestShotId = shot.ShotId;
         _sessionSubtotalDataStore.Update(currentSubSession);
     }
 }
    public void ProcessBestShotMessage(BestShotMessage bestShotMessage)
    {
      ShotEventArgs e = new ShotEventArgs
      {
        PrimaryScore = bestShotMessage.PrimaryScore,
        SecondaryScore = bestShotMessage.SecondaryScore,
        ProgramNumber = bestShotMessage.ProgramNumber,
        LaneNumber = bestShotMessage.LaneNumber,
        LaneId = bestShotMessage.LaneId,
        Ordinal = bestShotMessage.ShotNbr,
      };

      OnBestShot(e);
    }
        /// <summary>Stores the shot data to the repository and invokes module extension points.</summary>
        private void ShootingRangeOnShot(object sender, ShotEventArgs e)
        {
            if (_sessionsAwaitingProgramNumber.ContainsKey(e.LaneNumber))
            {
                Session session = _sessionsAwaitingProgramNumber[e.LaneNumber];
                _sessionsAwaitingProgramNumber.Remove(e.LaneNumber);
                _sessionsOngoing.Add(e.LaneNumber, session);
                session.ProgramNumber = e.ProgramNumber;
                _sessionDataStore.Create(session);

                SubSession subSession = session.CreateSubSession();
                _sessionSubtotalDataStore.Create(subSession);

                AddShotToSubsession(e, subSession);
            }
            else if (_sessionsOngoing.ContainsKey(e.LaneNumber))
            {
                Session session = _sessionsOngoing[e.LaneNumber];
                SubSession subSession = session.CurrentSubsession();
                if (subSession.SessionSubtotalId == 0)
                    _sessionSubtotalDataStore.Create(subSession);
                AddShotToSubsession(e, subSession);
            }
            else
            {
                throw new InvalidOperationException("Session is not available.");
            }
        }
 private void AddShotToSubsession(ShotEventArgs e, SubSession subSession)
 {
     Shot shot = new Shot
     {
         PrimaryScore = e.PrimaryScore,
         SecondaryScore = e.SecondaryScore,
         LaneNumber = e.LaneNumber,
         SubtotalId = subSession.SessionSubtotalId,
         Ordinal = e.Ordinal,
     };
     _shotDataStore.Create(shot);
 }
 public void ProcessShotMessage(ShotMessage shotMessage)
 {
   ShotEventArgs e = new ShotEventArgs
   {
     PrimaryScore = shotMessage.PrimaryScore,
     SecondaryScore = shotMessage.SecondaryScore,
     ProgramNumber = shotMessage.ProgramNumber,
     LaneNumber = shotMessage.LaneNumber,
     LaneId =  shotMessage.LaneId,
     Ordinal = shotMessage.ShotNbr,
   };
   OnShot(e);
 }
 protected virtual void OnShot(ShotEventArgs e)
 {
   EventHandler<ShotEventArgs> handler = Shot;
   if (handler != null) handler(this, e);
 }