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