Example #1
0
 private bool GameExists(GameDto game)
 {
     return
         GameRepository.GetGames(game.Team1, game.Team2)
             .ToArray()
             .Select(Mapper.Map)
             .Contains(game);
 }
Example #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;
        }
Example #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);
            }
        }
Example #4
0
 protected bool Equals(GameDto other)
 {
     return(Date.Equals(other.Date) && Score1 == other.Score1 && Score2 == other.Score2 &&
            Team1 == other.Team1 && Team2 == other.Team2);
 }
Example #5
0
		protected bool Equals(GameDto other)
		{
			return Date.Equals(other.Date) && Score1 == other.Score1 && Score2 == other.Score2 &&
			       Team1 == other.Team1 && Team2 == other.Team2;
		}
Example #6
0
 public static Game Map(GameDto dto)
 {
     return AutoMapper.Mapper.Map<Game>(dto);
 }