Пример #1
0
        /// <summary>
        /// Обработчик главной страницы
        /// </summary>
        public async Task <IActionResult> Index()
        {
            var model = new HomeIndexModel()
            {
                AvailableGames = GamePackage.ListAvailable()
                                 .Select(pkg => GameInfo.FromGamePackage(pkg))
                                 .ToList(),
                ActiveSessions = sessionsManager.GetSessions()
                                 .Select(s => SessionInfo.FromGameSession(s))
                                 .OrderBy(si => si.StartedAt)
                                 .ToList()
            };

            if (model.IsSigned)
            {
                try
                {
                    var playerSession = userCtx.GetGameSession();
                    model.PlayerSession = SessionInfo.FromGameSession(playerSession);
                    model.IsSigned      = true;
                }
                catch (NullReferenceException)
                {
                    await userCtx.PerformLogout();
                }
            }

            return(View(model));
        }