예제 #1
0
        public static GameViewModel CycleToGame(GameDto gameDto, int?seasonId = null)
        {
            var vm = new GameViewModel()
            {
                GameId          = gameDto.GameId,
                GameCycleStatus = gameDto.GameCycleStatus,
                StartDate       = gameDto.StartDate,
                HomeTeamId      = gameDto.HomeTeamId,
                HomeTeamScore   = gameDto.HomeTeamScore,
                GuestTeamId     = gameDto.GuestTeamId,
                GuestTeamScore  = gameDto.GuestTeamScore,
                Auditorium      = gameDto.Auditorium,
                HomeTeamLogo    = gameDto.HomeTeamLogo,
                GuestTeamLogo   = gameDto.GuestTeamLogo,
                CycleNumber     = gameDto.CycleNumber,
                LeagueId        = gameDto.LeagueId,
                LeagueName      = gameDto.LeagueName,
            };

            if (seasonId.HasValue)
            {
                TeamDetailsDto homeTeamDetails = gameDto.HomeTeamDetails.FirstOrDefault(x => x.SeasonId == seasonId);
                vm.HomeTeam = homeTeamDetails != null ? homeTeamDetails.TeamName : gameDto.HomeTeamTitle;

                TeamDetailsDto guestTeamDetails = gameDto.GuestTeamDetails.FirstOrDefault(x => x.SeasonId == seasonId);
                vm.GuestTeam = guestTeamDetails != null ? guestTeamDetails.TeamName : gameDto.GuestTeamTitle;
            }
            else
            {
                vm.HomeTeam  = gameDto.HomeTeamTitle;
                vm.GuestTeam = gameDto.GuestTeamTitle;
            }

            return(vm);
        }
예제 #2
0
 private async Task SetViewModelAsync()
 {
     ViewModel = await Mediator.Send(new GetTeamDetailsQuery(Id));
 }