public async Task <List <GameSessionViewModel> > GetGameSessionListAsync()
        {
            var gameSessionList = await _db.GameSessions.GetAllGameSessionsAsync();

            var gameSessionViewModels = GameSessionMethods.GetListGameSessionsViewModel(gameSessionList);

            _logger.LogInformation(LoggingEvents.GetGameSessionList, "Returned {Count} GameSessions", gameSessionViewModels.Count());
            return(gameSessionViewModels);
        }
        public async Task <List <GameSessionViewModel> > GetMyGameSessionListAsync(ClaimsPrincipal user)
        {
            var myGameSessionList = new List <GameSession>();

            string userID = user.FindAll(ClaimTypes.NameIdentifier).FirstOrDefault().Value;

            var gameSessionList = await _db.GameSessions.GetAllGameSessionsAsync();

            foreach (var gs in gameSessionList)
            {
                var gsPlayersID = gs.Players.Select(x => x.ApplicationUserID).ToList();
                if (gsPlayersID.Contains(userID))
                {
                    myGameSessionList.Add(gs);
                }
            }

            var gameSessionViewModels = GameSessionMethods.GetListGameSessionsViewModel(myGameSessionList);

            _logger.LogInformation(LoggingEvents.GetGameSessionList, "Returned {Count} GameSessions", gameSessionViewModels.Count());
            return(gameSessionViewModels);
        }
        public async Task <List <GameSessionViewModel> > SearchGameSessions(SearchGameSessionsViewModel model)
        {
            var searchParameter = new SearchParameters()
            {
                GameSessionName = model.SearchGameSessionName
            };

            if (model.SearchGameSessionDateFrom.HasValue)
            {
                searchParameter.StartDate = model.SearchGameSessionDateFrom.Value;
            }
            if (model.SearchGameSessionDateTo.HasValue)
            {
                searchParameter.EndDate = model.SearchGameSessionDateTo.Value;
            }
            var gameSessionList = await _db.GameSessions.SearchGameSession(searchParameter);

            var gameSessionViewModels = GameSessionMethods.GetListGameSessionsViewModel(gameSessionList.Where(x => x.IsCanceled == false).ToList());

            _logger.LogInformation(LoggingEvents.GetGameSessionList, "Returned {Count} GameSessions", gameSessionViewModels.Count());
            return(gameSessionViewModels);
        }