コード例 #1
0
ファイル: BowlingLineService.cs プロジェクト: pwhyton/CTM
        public virtual BowlingLine RecordBowlingLine(BowlingLine bowlingLine)
        {
            _bowlingLineRepository.Persist(bowlingLine);

            return bowlingLine;

        }
コード例 #2
0
ファイル: BowlingScoringStrategy.cs プロジェクト: pwhyton/CTM
        /// <summary>
        /// accepts a bowling line with a collection of players with scores in string format and uses the parser to 
        /// get the frame scores and then the injected calculator to add them up.
        /// </summary>
        /// <param name="bowlingLine"></param>
        /// <returns></returns>
        public void CalculateScores(BowlingLine bowlingLine)
        {
            if (bowlingLine == null)
            {
                throw new TenpinBowlingException("Bowling Line cannot be null");
            }

            if (bowlingLine.Players == null || !bowlingLine.Players.Any())
            {
                throw new TenpinBowlingException("Bowling Line has no player scores");
            }


            foreach(var player in bowlingLine.Players)
            {
                var scores = _bowlingScoreParser.ParseScores(player.RecordedScore).ToList();

                var frames = _bowlingFrameBuilder.BuildScores(scores).ToList();

                ValidateFrames(frames);

                var totalScore = _scoreCalculator.CalculateTotalScore(frames);

                player.TotalScore = totalScore;

            }
        }
コード例 #3
0
ファイル: AutoMapperConfig.cs プロジェクト: pwhyton/CTM
        public static void CreateMappings()
        {
          

            Mapper.CreateMap<AddBowlingLineModel, BowlingLine>()
            .ConstructUsing(src =>
            {
                var bowlingLine = new BowlingLine(Mapper.Map<List<BowlingLineScore>>(src.BowlingLineScores));
                
                return bowlingLine;
            });

            Mapper.CreateMap<BowlingLineScoreModel, BowlingLineScore>()
                .ConstructUsing(src =>
                {
                    var bowlingLineScore = new BowlingLineScore(src.Name, src.Scores);

                    return bowlingLineScore;
                });


            Mapper.CreateMap<BowlingLine, BowlingLineSummaryModel>()
                .ConstructUsing(src =>
                {
                    var summary = new BowlingLineSummaryModel {BowlerSummaries = new List<BowlerSummaryModel>()};
                    foreach (var player in src.Players)
                    {
                        summary.BowlerSummaries.Add(Mapper.Map<BowlerSummaryModel>(player));
                    }

                    return summary;
                });

            Mapper.CreateMap<Bowler, BowlerSummaryModel>();
                


        }
コード例 #4
0
ファイル: BowlingLineRepository.cs プロジェクト: pwhyton/CTM
 public void Persist(BowlingLine bowlingLine)
 {
 
 }