コード例 #1
0
        public IActionResult Details(string playerId)
        {
            if (playerId == null)
            {
                return(RedirectToAction("List"));
            }
            var player  = _playerController.GetPlayerById(playerId);
            var actions = _playerController.GetPlayerActions(playerId);
            var saves   = _playerController.GetPlayerGameSaves(playerId);
            var model   = new PlayerDetailsModel()
            {
                actionCount   = player.Actions.Count,
                name          = player.Name,
                platform      = PlayerPlatformResolver.ResolvePlatformFromPlayer(player).ToString(),
                recentActions = new List <PlayerActionModel>(),
                gameSaves     = new List <GameSaveItemModel>(),
                id            = player.PlayerId
            };

            var lastAction = actions.OrderByDescending(b => b.Time).FirstOrDefault();

            if (lastAction != null)
            {
                model.lastAction = lastAction.Time;
                var recentActions = actions.OrderByDescending(b => b.Time);
                foreach (var action in recentActions)
                {
                    var resolved = _actionResolver.ResolveAction(action, TimeSpan.FromMinutes(10));
                    if (resolved != null)
                    {
                        model.recentActions.Add(new PlayerActionModel
                        {
                            currentStateText = resolved.CurrentStateText,
                            gameName         = action.GameName,
                            lastOptionText   = resolved.StateOptionTaken
                        });
                    }
                }
            }

            model.gameSaves = saves.Select(a => new GameSaveItemModel
            {
                gameName = a.PlayerGameSave.GameName, dateCreated = a.CreatedDate, saveId = a.PlayerGameSaveId
            }).ToList();
            return(View(model));
        }
コード例 #2
0
        public IActionResult List()
        {
            var dbTokens   = _accessTokenService.ListTokens();
            var itemModels = dbTokens.Select(a => new AlphaAccessItemModel
            {
                AccessCode     = a.Token,
                LastActivated  = a.LastActivated,
                PlayerName     = a.Player?.Name,
                PlayerPlatform = PlayerPlatformResolver.ResolvePlatformFromPlayer(a.Player).ToString(),
                HoursAllowed   = a.HoursForRefresh,
                Id             = a.Id
            }).ToList();

            return(View(new ViewModelAlphaAccessList {
                AccessDescriptors = itemModels
            }));
        }
コード例 #3
0
        public ActionResult List(string playerPlatformFilter = "", string playerNameFilter = "", int pageNumber = 1, int pageSize = 25)
        {
            ViewBag.Message = "Players";

            var model = new ViewModelPlayerList();

            model.PageSize = pageSize;

            if (pageNumber < 0)
            {
                model.PageNumber = 0;
            }

            (List <PlayerListModel> players, int count)result = (null, 0);
            if (Enum.TryParse <PlatformType>(playerPlatformFilter, out var platformType))
            {
                result = _playerController.ListPlayers(platformType, playerNameFilter, pageNumber - 1, pageSize);
            }
            else
            {
                result = _playerController.ListPlayers(PlatformType.NONE, playerNameFilter, pageNumber - 1, pageSize);
            }

            model.Players = new List <ViewModelPlayer>();
            result.players.ForEach(a =>
            {
                var vmP  = new ViewModelPlayer();
                vmP.name = a.Name;
                if (a.LastAction != null)
                {
                    vmP.actionCount = a.ActionCount;
                    var lastAction  = a.LastAction;
                    if (lastAction != null)
                    {
                        vmP.lastAction = lastAction.Time;
                    }
                }
                else
                {
                    vmP.actionCount = 0;
                    vmP.lastAction  = default(DateTime);
                }
                vmP.id        = a.Id;
                vmP.platform  = PlayerPlatformResolver.ResolvePlatformFromPlayer(a).ToString();
                model.Players = model.Players;
                model.Players.Add(vmP);
            });


            model.PageNumber           = pageNumber;
            model.PlayerNameFilter     = playerNameFilter;
            model.PlayerPlatformFilter = playerPlatformFilter;
            model.NumberOfPages        = (result.count - 1) / pageSize;
            model.TotalPlayersCount    = result.count;

            if (model.Players.Count == 0 && model.PageNumber > 1)
            {
                return(List(playerPlatformFilter, playerNameFilter, model.NumberOfPages));
            }

            return(View(model));
        }