コード例 #1
0
        public BoardGameEntity Create(string name, PlayersRange playersRange = null, PlaytimeRange playtimeRange = null)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentException(nameof(name));
            }
            if (!IsPlayersRangeValid(playersRange))
            {
                throw new ArgumentException(nameof(playersRange));
            }
            if (!IsPlaytimeRangeValid(playtimeRange))
            {
                throw new ArgumentException(nameof(playtimeRange));
            }

            var boardGame = new BoardGameEntity
            {
                Id            = Guid.NewGuid(),
                Name          = name,
                PlayersRange  = playersRange,
                PlaytimeRange = playtimeRange
            };

            return(boardGame);
        }
コード例 #2
0
 private bool IsPlayersRangeValid(PlayersRange playersRange)
 {
     return(playersRange == null ||
            (playersRange.From > 0 &&
             playersRange.To >= playersRange.From));
 }