public ActionResult Index() { using (var context = new FcDeHoekContext()) { var model = new HomeModel { CurrentDivision = GetCurrentDivision(context), PreviousGame = GameQueries.GetPreviousGame(context), NextGame = GameQueries.GetNextGame(context), NextGames = GameQueries.GetNextGames(context).ToList() }; if (model.PreviousGame != null) { model.PreviousGameHomeTeam = TeamQueries.GetTeamById(context, model.PreviousGame.IdHomeTeam); model.PreviousGameAwayTeam = TeamQueries.GetTeamById(context, model.PreviousGame.IdAwayTeam); model.PreviousGameResult = model.PreviousGameHomeTeam.IdTeam == 1 ? eResult.GetResult(model.PreviousGame.GoalsHomeTeam, model.PreviousGame.GoalsAwayTeam) : eResult.GetResult(model.PreviousGame.GoalsAwayTeam, model.PreviousGame.GoalsHomeTeam); } if (model.NextGame != null) { model.NextGameHomeTeam = TeamQueries.GetTeamById(context, model.NextGame.IdHomeTeam); model.NextGameAwayTeam = TeamQueries.GetTeamById(context, model.NextGame.IdAwayTeam); } model.AllTeams = context.Teams.ToList(); return(View(model)); } }
public void GetTeamsByIdCompetition_TeamsForThatCompetitionExist_ReturnsTeamList() { var competition = CompetitionCommands.SaveCompetition(new Competition { Name = RandomUtil.GetRandomString(), Description = RandomUtil.GetRandomString(100) }, Context); var serie1 = SerieCommands.SaveSerie(new Serie { Description = RandomUtil.GetRandomString(), IdCompetition = competition.IdCompetition }, Context); var serie2 = SerieCommands.SaveSerie(new Serie { Description = RandomUtil.GetRandomString(), IdCompetition = competition.IdCompetition }, Context); TeamCommands.SaveTeam(new Team { Name = RandomUtil.GetRandomString(), Description = RandomUtil.GetRandomString(), IdSerie = serie1.IdSerie }, Context); TeamCommands.SaveTeam(new Team { Name = RandomUtil.GetRandomString(), Description = RandomUtil.GetRandomString(), IdSerie = serie1.IdSerie }, Context); TeamCommands.SaveTeam(new Team { Name = RandomUtil.GetRandomString(), Description = RandomUtil.GetRandomString(), IdSerie = serie2.IdSerie }, Context); TeamCommands.SaveTeam(new Team { Name = RandomUtil.GetRandomString(), Description = RandomUtil.GetRandomString(), IdSerie = serie2.IdSerie }, Context); var teams = TeamQueries.GetTeamsByIdCompetition(Context, competition.IdCompetition); Assert.IsNotNull(teams); Assert.AreEqual(4, teams.Count); }
private List <GameModel> GetGameModels(FcDeHoekContext context, List <Game> calendars, bool setIsNextGame = true) { var games = new List <GameModel>(); Game nextGame = null; if (setIsNextGame) { nextGame = GameQueries.GetNextGame(context); } foreach (var calendar in calendars) { if (calendar.GameCompetition == null) { calendar.GameCompetition = context.BaseDomains.FirstOrDefault(bd => bd.IdBaseDomain == calendar.IdCompetition); } if (calendar.GameHomeTeam == null) { calendar.GameHomeTeam = TeamQueries.GetTeamById(context, calendar.IdHomeTeam); } if (calendar.GameAwayTeam == null) { calendar.GameAwayTeam = TeamQueries.GetTeamById(context, calendar.IdAwayTeam); } games.Add(new GameModel { IdGame = calendar.IdGame, Competition = calendar.GameCompetition?.Description, MatchDay = calendar.MatchDate.Date, IdHomeTeam = calendar.IdHomeTeam, HomeTeam = calendar.GameHomeTeam?.Name, AwayTeam = calendar.GameAwayTeam?.Name, IdAwayTeam = calendar.IdAwayTeam, GameResult = calendar.IdHomeTeam == 1 ? eResult.GetResult(calendar.GoalsHomeTeam, calendar.GoalsAwayTeam) : eResult.GetResult(calendar.GoalsAwayTeam, calendar.GoalsHomeTeam), Result = calendar.NotPlayed ? "Afgelast" : !calendar.Forfait ? calendar.GoalsHomeTeam != null ? $"{calendar.GoalsHomeTeam} - {calendar.GoalsAwayTeam}" : " - " : calendar.GoalsHomeTeam != null ? $"{calendar.GoalsHomeTeam} - {calendar.GoalsAwayTeam} (F.F.)" : "F.F.", IsNextGame = calendar.IdGame == nextGame?.IdGame }); } return(games); }
public override void GetEntityById_EntityDoesExist_ReturnsEntity() { var name = RandomUtil.GetRandomString(); var team = TeamCommands.SaveTeam(new Team { Description = RandomUtil.GetRandomString(200), Name = name }, Context); var teamDb = TeamQueries.GetTeamById(Context, team.IdTeam); Assert.IsNotNull(teamDb); Assert.AreEqual(name, teamDb.Name); }
public void GetTeamsByIdSerie_TeamsForThatSerieExist_ReturnsTeamList() { var serie = SerieCommands.SaveSerie(new Serie { Description = RandomUtil.GetRandomString() }, Context); TeamCommands.SaveTeam(new Team { Name = RandomUtil.GetRandomString(), Description = RandomUtil.GetRandomString(), IdSerie = serie.IdSerie }, Context); TeamCommands.SaveTeam(new Team { Name = RandomUtil.GetRandomString(), Description = RandomUtil.GetRandomString(), IdSerie = serie.IdSerie }, Context); var teams = TeamQueries.GetTeamsByIdSerie(Context, serie.IdSerie); Assert.IsNotNull(teams); Assert.AreEqual(2, teams.Count); }
public void GetTeamsByIdCompetition_TeamsForThatCompetitionDoesNotExist_ReturnsEmptyList() { Assert.IsEmpty(TeamQueries.GetTeamsByIdCompetition(Context, -1)); }
public void GetTeamsByIdSerie_NoTeamsForThatSerieExist_ReturnsEmptyList() { Assert.IsEmpty(TeamQueries.GetTeamsByIdSerie(Context, -1)); }
public override void GetEntityById_EntityDoesNotExist_ReturnsNull() { Assert.IsNull(TeamQueries.GetTeamById(Context, -1)); }