Ejemplo n.º 1
0
        /// <summary>
        /// Plays the event.
        /// </summary>
        /// <param name="domainEvent">The domain event.</param>
        private void PlayEvent(MeasuredCourseAddedEvent domainEvent)
        {
            MeasuredCourse measuredCourse =
                MeasuredCourse.Create(domainEvent.MeasuredCourseId, domainEvent.Name, domainEvent.TeeColour, domainEvent.StandardScratchScore);

            this.MeasuredCourses.Add(measuredCourse);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Plays the event.
        /// </summary>
        /// <param name="domainEvent">The domain event.</param>
        private void PlayEvent(HoleAddedToMeasuredCourseEvent domainEvent)
        {
            // Find the measured course
            MeasuredCourse measuredCourse = this.MeasuredCourses.Single(m => m.MeasuredCourseId == domainEvent.MeasuredCourseId);

            measuredCourse.AddHole(Hole.Create(domainEvent.HoleNumber, domainEvent.LengthInYards, domainEvent.LengthInMeters, domainEvent.Par, domainEvent.StrokeIndex));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Gets the measured course.
        /// </summary>
        /// <param name="measuredCourseId">The measured course identifier.</param>
        /// <returns></returns>
        /// <exception cref="NotFoundException">No measured course found for Club {this.Name} with Measured Course Id {measuredCourseId}</exception>
        public MeasuredCourseDataTransferObject GetMeasuredCourse(Guid measuredCourseId)
        {
            Boolean measuredCourseFound = this.MeasuredCourses.Any(m => m.MeasuredCourseId == measuredCourseId);

            if (!measuredCourseFound)
            {
                throw new NotFoundException($"No measured course found for Club {this.Name} with Measured Course Id {measuredCourseId}");
            }

            MeasuredCourse measuredCourse = this.MeasuredCourses.Where(m => m.MeasuredCourseId == measuredCourseId).Single();

            MeasuredCourseDataTransferObject result = new MeasuredCourseDataTransferObject
            {
                Name                 = measuredCourse.Name,
                MeasuredCourseId     = measuredCourse.MeasuredCourseId,
                StandardScratchScore = measuredCourse.StandardScratchScore,
                TeeColour            = measuredCourse.TeeColour,
                Holes                = new List <HoleDataTransferObject>()
            };

            foreach (Hole measuredCourseHole in measuredCourse.Holes)
            {
                result.Holes.Add(new HoleDataTransferObject
                {
                    HoleNumber     = measuredCourseHole.HoleNumber,
                    Par            = measuredCourseHole.Par,
                    LengthInYards  = measuredCourseHole.LengthInYards,
                    StrokeIndex    = measuredCourseHole.StrokeIndex,
                    LengthInMeters = measuredCourseHole.LengthInMeters
                });
            }

            return(result);
        }