Exemplo n.º 1
0
        public async Task <IActionResult> GetPage2([FromBody] NoticeBoardRequest request = null)
        {
            PagedResult <NoticeBoardResponse> pagedResult = await NoticeBoards.GetPageAsync(request.userId, request);

            return(ApiOk(pagedResult));
        }
Exemplo n.º 2
0
        public async Task <PagedResult <NoticeBoardResponse> > GetPageAsync(long userId, NoticeBoardRequest request = null)
        {
            if (userId > 0)
            {
                PagedResult <NoticeBoardResponse> pagedResult = await _context

                                                                .NoticeBoards.AsQueryable().Include(a => a.Country).Include(a => a.City).Include(a => a.QuizTheme).Include(a => a.AuthUser).Where(a => a.AuthUser.Id == userId)
                                                                .Select(i => new NoticeBoardResponse

                {
                    Id          = i.Id,
                    Name        = i.Name,
                    DateWhen    = i.DateWhen,
                    CityId      = i.CityId,
                    AuthUserId  = i.AuthUserId,
                    AuthUser    = i.AuthUser,
                    Country     = i.Country,
                    CountryId   = i.CountryId,
                    City        = i.City,
                    QuizThemeId = i.QuizThemeId,
                    QuizTheme   = i.QuizTheme
                })
                                                                .ToPagedResultAsync(request);

                return(pagedResult);
            }
            else
            {
                PagedResult <NoticeBoardResponse> pagedResult = await _context

                                                                .NoticeBoards.AsQueryable().Include(a => a.Country).Include(a => a.City).Include(a => a.QuizTheme).Include(a => a.AuthUser)
                                                                .Select(i => new NoticeBoardResponse

                {
                    Id          = i.Id,
                    Name        = i.Name,
                    DateWhen    = i.DateWhen,
                    CityId      = i.CityId,
                    AuthUserId  = i.AuthUserId,
                    AuthUser    = i.AuthUser,
                    Country     = i.Country,
                    CountryId   = i.CountryId,
                    City        = i.City,
                    QuizThemeId = i.QuizThemeId,
                    QuizTheme   = i.QuizTheme
                })
                                                                .ToPagedResultAsync(request);

                return(pagedResult);
            }
            //var userId = this.User.FindFirstValue(ClaimTypes.NameIdentifier);
        }