public async Task <ActionResult> Index() { var clubs = (await _clubSessionRegisterAppService.GetClubs()).Items; var clubSessionResultRequestDto = new PagedClubSessionResultRequestDto(); var clubSessions = (await _clubSessionRegisterAppService.GetClubSessions(clubSessionResultRequestDto)).Items; var clubSessionRegisterResultRequestDto = new PagedClubSessionRegisterResultRequestDto() { UserId = Convert.ToInt64(User.Identity.GetUserId()) }; var clubSessionRegisters = (await _clubSessionRegisterAppService.GetAllAsync(clubSessionRegisterResultRequestDto)).Items; var model = new ClubSessionRegisterListViewModel() { Clubs = clubs, ClubSessions = clubSessions }; return(View(model)); }
public async Task <PagedResultDto <ClubSessionForUserDto> > GetClubSessions(PagedClubSessionResultRequestDto input) { if (input.MaxResultCount <= 0) { input.MaxResultCount = 10; } if (input.SkipCount <= 0) { input.SkipCount = 0; } long currentUserId = Convert.ToInt64(AbpSession.UserId); var clubSessionsQuery = _clubSessionRepository .GetAllIncluding(x => x.Club) .Where(x => x.IsActive && x.Club.IsActive); var totalCount = await clubSessionsQuery.CountAsync(); var items = await clubSessionsQuery .Skip(input.SkipCount) .Take(input.MaxResultCount) .ToListAsync(); var userRegistrations = await Repository .GetAllListAsync(x => x.RegisteredUserId == currentUserId); PagedResultDto <ClubSessionForUserDto> result = new PagedResultDto <ClubSessionForUserDto>(); result.TotalCount = totalCount; var clubSessions = ObjectMapper.Map <List <ClubSessionForUserDto> >(items); clubSessions.Where(x => userRegistrations.Any(z => z.ClubSessionId == x.Id)).ToList().ForEach(x => x.Registered = true); result.Items = clubSessions; return(result); }