Пример #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);
        }
Пример #2
0
 public UserInfo GetUserInfo()
 {
     if (this.User.Identity.IsAuthenticated)
     {
         var steamId   = UserExtensions.GetSteamId(this.User);
         var steamInfo = _steamService.GetSteamInfo(steamId);
         var userName  = steamInfo.FirstOrDefault(u => u.Name == "personaname")?.Value;
         var mmr       = _trackerService.GetMmr(steamId).Result;
         return(new UserInfo {
             SteamId = steamId, DisplayName = userName, Mmr = mmr
         });
     }
     return(null);
 }
Пример #3
0
        public IActionResult StartSearch([FromBody] UserInfo userInfo)
        {
            var steamId = UserExtensions.GetSteamId(this.User);

            if (string.IsNullOrWhiteSpace(steamId) || !userInfo.Servers.Any())
            {
                return(BadRequest());
            }
            var mmr = _trackerService.GetMmr(steamId).Result;

            userInfo.SteamId = steamId;
            userInfo.Mmr     = mmr;
            _matchmakingService.StartSearch(userInfo);
            return(Ok());
        }