public async Task <ActionResult <CursorPaginatedResponse <ExerciseForReturnDto> > > GetExercisesForEquipmentAsync(int id, [FromQuery] CursorPaginationParams searchParams) { var exerciseSearchParams = new ExerciseSearchParams { First = searchParams.First, After = searchParams.After, Last = searchParams.Last, Before = searchParams.Before, IncludeTotal = searchParams.IncludeTotal, EquipmentId = new List <int> { id } }; var exercises = await exerciseRepository.SearchAsync(exerciseSearchParams); var paginatedResponse = CursorPaginatedResponse <ExerciseForReturnDto> .CreateFrom(exercises, mapper.Map <IEnumerable <ExerciseForReturnDto> >); return(Ok(paginatedResponse)); }
public async Task <ActionResult <CursorPaginatedResponse <ExerciseForReturnDetailedDto> > > GetFavoriteExercisesForUserDetailedAsync(int userId, [FromQuery] ExerciseSearchParams searchParams) { if (userId != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value)) { return(Unauthorized()); } var exercises = await userRepository.GetFavoriteExercisesForUserDetailedAsync(userId, searchParams); var paginatedResponse = CursorPaginatedResponse <ExerciseForReturnDetailedDto> .CreateFrom(exercises, mapper.Map <IEnumerable <ExerciseForReturnDetailedDto> >); return(Ok(paginatedResponse)); }
public Task <CursorPagedList <Exercise> > GetFavoriteExercisesForUserDetailedAsync(int userId, ExerciseSearchParams searchParams) { IQueryable <Exercise> query = context.Users .Where(u => u.Id == userId) .SelectMany(u => u.FavoriteExercises.Select(fe => fe.Exercise)); return(exerciseRepository.SearchDetailedAsync(query, searchParams)); }
public async Task <ActionResult <CursorPaginatedResponse <ExerciseForReturnDetailedDto> > > GetExercisesDetailedAsync([FromQuery] ExerciseSearchParams searchParams) { var exercises = await exerciseRepository.SearchDetailedAsync(searchParams); var paginatedResponse = CursorPaginatedResponse <ExerciseForReturnDetailedDto> .CreateFrom(exercises, mapper.Map <IEnumerable <ExerciseForReturnDetailedDto> >); return(Ok(paginatedResponse)); }