Exemple #1
0
 private bool GameExists(GameDto game)
 {
     return
         GameRepository.GetGames(game.Team1, game.Team2)
             .ToArray()
             .Select(Mapper.Map)
             .Contains(game);
 }
Exemple #2
0
        private static bool ValidateGame(GameDto game)
        {
            if (game.Score1 < 0)
            {
                return false;
            }
            if (game.Score2 < 0)
            {
                return false;
            }
            if (game.Team1 == null || game.Team2 == null)
            {
                return false;
            }
            if (string.IsNullOrWhiteSpace(game.Team1) || string.IsNullOrWhiteSpace(game.Team2))
            {
                return false;
            }

            return true;
        }
Exemple #3
0
        public bool ValidateAndAdd(GameDto game)
        {
            try
            {
                if (!ValidateGame(game))
                {
                    return false;
                }
                if (GameExists(game))
                {
                    return true;
                }

                GameRepository.AddGame(Mapper.Map(game));
                return true;
            }
            catch (Exception exception)
            {
                throw new LogicException("Could not validate game", exception);
            }
        }
Exemple #4
0
 protected bool Equals(GameDto other)
 {
     return(Date.Equals(other.Date) && Score1 == other.Score1 && Score2 == other.Score2 &&
            Team1 == other.Team1 && Team2 == other.Team2);
 }
Exemple #5
0
		protected bool Equals(GameDto other)
		{
			return Date.Equals(other.Date) && Score1 == other.Score1 && Score2 == other.Score2 &&
			       Team1 == other.Team1 && Team2 == other.Team2;
		}
Exemple #6
0
 public static Game Map(GameDto dto)
 {
     return AutoMapper.Mapper.Map<Game>(dto);
 }