Exemplo n.º 1
0
        /// <summary>
        /// Handles the specific domain event.
        /// </summary>
        /// <param name="domainEvent">The domain event.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        private async Task HandleSpecificDomainEvent(HandicapAdjustedEvent domainEvent,
                                                     CancellationToken cancellationToken)
        {
            await this.Manager.UpdatePlayerMembershipToReporting(domainEvent, cancellationToken);

            await this.Manager.UpdatePlayerHandicapRecordToReporting(domainEvent, cancellationToken);
        }
        /// <summary>
        /// Adjusts the handicap.
        /// </summary>
        /// <param name="handicapAdjustmentDataTransferObject">The handicap adjustment data transfer object.</param>
        /// <param name="tournamentId">The tournament identifier.</param>
        /// <param name="golfClubId">The golf club identifier.</param>
        /// <param name="measuredCourseId">The measured course identifier.</param>
        /// <param name="scoreDate">The score date.</param>
        public void AdjustHandicap(HandicapAdjustmentDataTransferObject handicapAdjustmentDataTransferObject,
                                   Guid tournamentId,
                                   Guid golfClubId,
                                   Guid measuredCourseId,
                                   DateTime scoreDate)
        {
            Guard.ThrowIfNull(handicapAdjustmentDataTransferObject, typeof(ArgumentNullException), "Handicap Adjustment details must be provided to adjust a players handicap");
            Guard.ThrowIfInvalidGuid(tournamentId, typeof(ArgumentNullException), "Tournament Id must be provided to adjust a players handicap");
            Guard.ThrowIfInvalidGuid(golfClubId, typeof(ArgumentNullException), "Golf Club Id must be provided to adjust a players handicap");
            Guard.ThrowIfInvalidGuid(measuredCourseId, typeof(ArgumentNullException), "Measured Course Id must be provided to adjust a players handicap");
            Guard.ThrowIfInvalidDate(scoreDate, typeof(ArgumentNullException), "Score Date must be provided to adjust a players handicap");

            this.CheckIfPlayerHasBeenRegistered();

            this.CheckNotDuplicateHandicapAdjustment(handicapAdjustmentDataTransferObject, tournamentId, golfClubId, measuredCourseId, scoreDate);

            HandicapAdjustedEvent handicapAdjustedEvent = HandicapAdjustedEvent.Create(this.AggregateId,
                                                                                       handicapAdjustmentDataTransferObject.NumberOfStrokesBelowCss,
                                                                                       handicapAdjustmentDataTransferObject.AdjustmentValuePerStroke,
                                                                                       handicapAdjustmentDataTransferObject.TotalAdjustment,
                                                                                       tournamentId,
                                                                                       golfClubId,
                                                                                       measuredCourseId,
                                                                                       scoreDate);

            this.ApplyAndPend(handicapAdjustedEvent);
        }
Exemplo n.º 3
0
 public static HandicapAdjustedEvent GetHandicapAdjustedEvent()
 {
     return(HandicapAdjustedEvent.Create(PlayerTestData.AggregateId,
                                         PlayerTestData.NumberOfStrokesBelowCss,
                                         PlayerTestData.AdjustmentValuePerStroke,
                                         PlayerTestData.TotalAdjustment,
                                         PlayerTestData.TournamentId,
                                         PlayerTestData.GolfClubId,
                                         PlayerTestData.MeasuredCourseId,
                                         PlayerTestData.ScoreDate));
 }
        /// <summary>
        /// Plays the event.
        /// </summary>
        /// <param name="handicapAdjustedEvent">The handicap adjusted event.</param>
        private void PlayEvent(HandicapAdjustedEvent handicapAdjustedEvent)
        {
            HandicapAdjustment handicapAdjustment = HandicapAdjustment.Create(handicapAdjustedEvent.NumberOfStrokesBelowCss,
                                                                              handicapAdjustedEvent.AdjustmentValuePerStroke,
                                                                              handicapAdjustedEvent.TotalAdjustment,
                                                                              handicapAdjustedEvent.TournamentId,
                                                                              handicapAdjustedEvent.GolfClubId,
                                                                              handicapAdjustedEvent.MeasuredCourseId,
                                                                              handicapAdjustedEvent.ScoreDate);

            this.HandicapAdjustments.Add(handicapAdjustment);
            this.ExactHandicap   += handicapAdjustedEvent.TotalAdjustment;
            this.PlayingHandicap  = this.CalculatePlayingHandicap(this.ExactHandicap);
            this.HandicapCategory = this.CalculateHandicapCategory(this.PlayingHandicap);
        }
        public void HandicapAdjustedEvent_CanBeCreated_IsCreated()
        {
            HandicapAdjustedEvent handicapAdjustedEvent = HandicapAdjustedEvent.Create(PlayerTestData.AggregateId, PlayerTestData.NumberOfStrokesBelowCss,
                                                                                       PlayerTestData.AdjustmentValuePerStroke, PlayerTestData.TotalAdjustment,
                                                                                       PlayerTestData.TournamentId, PlayerTestData.GolfClubId,
                                                                                       PlayerTestData.MeasuredCourseId, PlayerTestData.ScoreDate);

            handicapAdjustedEvent.ShouldNotBeNull();
            handicapAdjustedEvent.AggregateId.ShouldBe(PlayerTestData.AggregateId);
            handicapAdjustedEvent.EventId.ShouldNotBe(Guid.Empty);
            handicapAdjustedEvent.EventCreatedDateTime.ShouldNotBe(DateTime.MinValue);
            handicapAdjustedEvent.NumberOfStrokesBelowCss.ShouldBe(PlayerTestData.NumberOfStrokesBelowCss);
            handicapAdjustedEvent.AdjustmentValuePerStroke.ShouldBe(PlayerTestData.AdjustmentValuePerStroke);
            handicapAdjustedEvent.TotalAdjustment.ShouldBe(PlayerTestData.TotalAdjustment);
            handicapAdjustedEvent.TournamentId.ShouldBe(PlayerTestData.TournamentId);
            handicapAdjustedEvent.GolfClubId.ShouldBe(PlayerTestData.GolfClubId);
            handicapAdjustedEvent.MeasuredCourseId.ShouldBe(PlayerTestData.MeasuredCourseId);
            handicapAdjustedEvent.ScoreDate.ShouldBe(PlayerTestData.ScoreDate);
        }