コード例 #1
0
        public IActionResult GetAllByUser()
        {
            var user = userManager.GetUserAsync(User).Result;

            if (user == null)
            {
                return(BadRequest());
            }

            var mapper      = config.CreateMapper();
            var tournaments = tournamentService.Get(25, 1)
                              .Where(t =>
            {
                var players          = tournamentService.GetAllPlayersFromTournament(t.TournamentId);
                var hasUserInPlayers = players.FirstOrDefault(p => p.UserId == user.Id) != null;
                return(t.InitiatorId == user.Id || hasUserInPlayers);
            })
                              .ToList();

            // var tournaments = tournamentService.Get(pagingParameters.PageSize, pagingParameters.PageNumber);
            return(new JsonResult(mapper.Map <List <TournamentDTO>, List <TournamentViewModel> >(tournaments)));
        }