public async Task <ActionResult <CursorPaginatedResponse <ScheduledWorkoutForReturnDetailedDto> > > GetScheduledWorkoutsForUserDetailedAsync(int userId, [FromQuery] ScheduledWorkoutSearchParams searchParams) { if (userId != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value)) { return(Unauthorized()); } var workouts = await userRepository.GetScheduledWorkoutsForUserDetailedAsync(userId, searchParams); var paginatedResponse = CursorPaginatedResponse <ScheduledWorkoutForReturnDetailedDto> .CreateFrom(workouts, mapper.Map <IEnumerable <ScheduledWorkoutForReturnDetailedDto> >); return(Ok(paginatedResponse)); }
public Task <CursorPagedList <ScheduledWorkout> > GetScheduledWorkoutsForUserDetailedAsync(int userId, ScheduledWorkoutSearchParams searchParams) { IQueryable <ScheduledWorkout> query = context.ScheduledWorkouts .Where(wo => wo.Attendees.Any(attendee => attendee.UserId == userId)); return(scheduledWorkoutRepository.SearchDetailedAsync(query, searchParams)); }
public async Task <ActionResult <CursorPaginatedResponse <ScheduledWorkoutForReturnDetailedDto> > > GetScheduledWorkoutsDetailedAsync([FromQuery] ScheduledWorkoutSearchParams searchParams) { var workouts = await scheduledWorkoutRepository.SearchDetailedAsync(searchParams); var paginatedResponse = CursorPaginatedResponse <ScheduledWorkoutForReturnDetailedDto> .CreateFrom(workouts, mapper.Map <IEnumerable <ScheduledWorkoutForReturnDetailedDto> >); return(Ok(paginatedResponse)); }