public RoundDto CreateRound(RoundDto round)
        {
            RoundDto roundDto;

            using (var context = new BowlingScoreboardDbContextFactory().CreateDbContext())
            {
                var roundEntity = _mapper.Map <Round>(round);

                context.Rounds.Add(roundEntity);

                context.SaveChanges();

                roundDto = _mapper.Map <RoundDto>(roundEntity);

                roundDto.GameId = round.GameId;

                roundDto.PlayerId = round.PlayerId;
            }

            return(roundDto);
        }
        public GameDto CreateGame(int lineNumber, IEnumerable <PlayerDto> players)
        {
            GameDto gameDto;

            using (var context = new BowlingScoreboardDbContextFactory().CreateDbContext())
            {
                var lineId = context.Lines.SingleOrDefault(l => l.Number == lineNumber).Id;

                var playerEntities = _mapper.Map <ICollection <Player> >(players);

                var game = new Game()
                {
                    LineId  = lineId,
                    Players = playerEntities
                };

                context.Games.Add(game);
                context.SaveChanges();

                gameDto = _mapper.Map <GameDto>(game);
            }

            return(gameDto);
        }