Пример #1
0
        private ScrimEventViewModel GetEventViewModel(ScrimEvent scrimEvent)
        {
            var viewModel = new ScrimEventViewModel()
            {
                Id                    = scrimEvent.Id,
                SteamId               = scrimEvent.SteamId,
                OpponentSteamId       = scrimEvent.OpponentSteamId,
                TeamName              = scrimEvent.TeamName,
                EventDate             = scrimEvent.EventDate,
                MatchmakingPreference = scrimEvent.MatchmakingPreference,
                Collegiate            = scrimEvent.Collegiate,
                Servers               = scrimEvent.Servers,
                ScrimRequests         = new List <ScrimRequestViewModel>(),
                ChatLogs              = new List <ChatMessageViewModel>()
            };

            viewModel.DisplayName = _steamService.GetSteamDisplayName(scrimEvent.SteamId);
            viewModel.Mmr         = _trackerService.GetMmr(scrimEvent.SteamId).Result;
            if (scrimEvent.OpponentSteamId != null)
            {
                viewModel.OpponentDisplayName = _steamService.GetSteamDisplayName(scrimEvent.OpponentSteamId);
                viewModel.OpponentMmr         = _trackerService.GetMmr(scrimEvent.OpponentSteamId).Result;
            }

            if (scrimEvent.RequestList != null)
            {
                foreach (var request in scrimEvent.RequestList)
                {
                    var requestViewModel = GetRequestViewModel(request);
                    viewModel.ScrimRequests.Add(requestViewModel);
                }
            }
            if (scrimEvent.ChatLogs != null)
            {
                foreach (var log in scrimEvent.ChatLogs)
                {
                    viewModel.ChatLogs.Add(new ChatMessageViewModel {
                        Id = log.Id, Message = log.Message, Sent = log.Sent, SteamId = log.SteamId
                    });
                }
            }
            return(viewModel);
        }