public async Task <ActionResult <CursorPaginatedResponse <ExerciseForReturnDto> > > GetExercisesAsync([FromQuery] ExerciseSearchParameters searchParams)
        {
            var exercises = await exerciseRepository.SearchAsync(searchParams);

            var paginatedResponse = CursorPaginatedResponse <ExerciseForReturnDto> .CreateFrom(exercises, mapper.Map <IEnumerable <ExerciseForReturnDto> >);

            return(Ok(paginatedResponse));
        }
Exemplo n.º 2
0
        public async Task <ActionResult <CursorPaginatedResponse <ExerciseCategoryForReturnDetailedDto> > > GetExerciseCategoriesDetailedAsync([FromQuery] ExerciseCategorySearchParams searchParams)
        {
            var categories = await exerciseCategoryRepository.SearchDetailedAsync(searchParams);

            var paginatedResponse = CursorPaginatedResponse <ExerciseCategoryForReturnDetailedDto> .CreateFrom(categories, mapper.Map <IEnumerable <ExerciseCategoryForReturnDetailedDto> >);

            return(Ok(paginatedResponse));
        }
Exemplo n.º 3
0
        public async Task <ActionResult <CursorPaginatedResponse <WorkoutForReturnDetailedDto> > > GetWorkoutsDetailedAsync([FromQuery] WorkoutSearchParams searchParams)
        {
            var workouts = await workoutRepository.SearchDetailedAsync(searchParams);

            var paginatedResponse = CursorPaginatedResponse <WorkoutForReturnDetailedDto> .CreateFrom(workouts, mapper.Map <IEnumerable <WorkoutForReturnDetailedDto> >);

            return(Ok(paginatedResponse));
        }
        public async Task <ActionResult <CursorPaginatedResponse <BudgetDto> > > GetBudgetsAsync([FromQuery] BudgetQueryParameters searchParams)
        {
            var budgets = await budgetRepository.SearchAsync(searchParams);

            var paginatedResponse = CursorPaginatedResponse <BudgetDto> .CreateFrom(budgets, mapper.Map <IEnumerable <BudgetDto> >, searchParams.IncludeNodes, searchParams.IncludeEdges);

            return(Ok(paginatedResponse));
        }
Exemplo n.º 5
0
        public async Task <ActionResult <CursorPaginatedResponse <UserDto> > > GetUsersAsync([FromQuery] CursorPaginationParameters searchParams)
        {
            var users = await userRepository.SearchAsync(searchParams);

            var paginatedResponse = CursorPaginatedResponse <UserDto> .CreateFrom(users, mapper.Map <IEnumerable <UserDto> >, searchParams);

            return(Ok(paginatedResponse));
        }
Exemplo n.º 6
0
        public async Task <ActionResult <CursorPaginatedResponse <WorkoutInvitationForReturnDto> > > GetWorkoutInvitationsAsync([FromQuery] WorkoutInvitationSearchParams searchParams)
        {
            var invitations = await workoutInvitationRepository.SearchAsync(searchParams);

            var paginatedResponse = CursorPaginatedResponse <WorkoutInvitationForReturnDto> .CreateFrom(invitations, mapper.Map <IEnumerable <WorkoutInvitationForReturnDto> >);

            return(Ok(paginatedResponse));
        }
Exemplo n.º 7
0
        public async Task <ActionResult <CursorPaginatedResponse <EquipmentForReturnDetailedDto> > > GetEquipmentDetailedAsync([FromQuery] EquipmentSearchParams searchParams)
        {
            var equipment = await equipmentRepository.SearchDetailedAsync(searchParams);

            var paginatedResponse = CursorPaginatedResponse <EquipmentForReturnDetailedDto> .CreateFrom(equipment, mapper.Map <IEnumerable <EquipmentForReturnDetailedDto> >);

            return(Ok(paginatedResponse));
        }
Exemplo n.º 8
0
        public async Task <ActionResult <CursorPaginatedResponse <RoleForReturnDto> > > GetRolesAsync([FromQuery] CursorPaginationParams searchParams)
        {
            var roles = await userRepository.GetRolesAsync(searchParams);

            var paginatedResponse = CursorPaginatedResponse <RoleForReturnDto> .CreateFrom(roles, mapper.Map <IEnumerable <RoleForReturnDto> >);

            return(Ok(paginatedResponse));
        }
Exemplo n.º 9
0
        public async Task <ActionResult <CursorPaginatedResponse <WorkoutCompletionRecord> > > GetWorkoutCompletionRecordsForUserAsync(int userId, [FromQuery] CompletionRecordSearchParams searchParams)
        {
            var records = await userRepository.GetWorkoutCompletionRecordsForUserAsync(userId, searchParams);

            var paginatedResponse = new CursorPaginatedResponse <WorkoutCompletionRecord>(records);

            return(Ok(paginatedResponse));
        }
Exemplo n.º 10
0
        public async Task <ActionResult <CursorPaginatedResponse <MuscleForReturnDetailedDto> > > GetMusclesDetailedAsync([FromQuery] CursorPaginationParams searchParams)
        {
            var muscles = await muscleRepository.SearchDetailedAsync(searchParams);

            var paginatedResponse = CursorPaginatedResponse <MuscleForReturnDetailedDto> .CreateFrom(muscles, mapper.Map <IEnumerable <MuscleForReturnDetailedDto> >);

            return(Ok(paginatedResponse));
        }
Exemplo n.º 11
0
        public async Task <ActionResult <CursorPaginatedResponse <IncomeDto> > > GetIncomesAsync([FromQuery] CursorPaginationParameters searchParams)
        {
            var expenses = await incomeRepository.SearchAsync(searchParams);

            var paginatedResponse = CursorPaginatedResponse <IncomeDto> .CreateFrom(expenses, mapper.Map <IEnumerable <IncomeDto> >, searchParams.IncludeNodes, searchParams.IncludeEdges);

            return(Ok(paginatedResponse));
        }
Exemplo n.º 12
0
        public async Task <ActionResult <CursorPaginatedResponse <ScheduledWorkoutForReturnDto> > > GetScheduledWorkoutsForUserAsync(int userId, [FromQuery] ScheduledWorkoutSearchParams searchParams)
        {
            if (userId != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value))
            {
                return(Unauthorized());
            }

            var workouts = await userRepository.GetScheduledWorkoutsForUserAsync(userId, searchParams);

            var paginatedResponse = CursorPaginatedResponse <ScheduledWorkoutForReturnDto> .CreateFrom(workouts, mapper.Map <IEnumerable <ScheduledWorkoutForReturnDto> >);

            return(Ok(paginatedResponse));
        }
Exemplo n.º 13
0
        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 async Task <ActionResult <CursorPaginatedResponse <UserForReturnDto> > > GetScheduledWorkoutAttendeesAsync(int id, [FromQuery] CursorPaginationParams searchParams)
        {
            var workout = await scheduledWorkoutRepository.GetByIdAsync(id);

            if (workout == null)
            {
                return(NotFound());
            }

            var attendees = await scheduledWorkoutRepository.GetScheduledWorkoutAttendeesAsync(id, searchParams);

            var paginatedResponse = CursorPaginatedResponse <UserForReturnDto> .CreateFrom(attendees, mapper.Map <IEnumerable <UserForReturnDto> >);

            return(Ok(paginatedResponse));
        }
Exemplo n.º 15
0
        public async Task <ActionResult <CursorPaginatedResponse <GymForReturnDto> > > GetUserGymsAsync([FromRoute] int userId, [FromQuery] CursorPaginationParameters searchParams)
        {
            if (!IsUserAuthorizedForResource(userId))
            {
                return(Forbidden("You can only access your own gyms."));
            }

            var gymSearchParams = this.mapper.Map <GymSearchParameters>(searchParams);

            gymSearchParams.UserId = userId;

            var gyms = await gymRepository.SearchAsync(gymSearchParams);

            var paginatedResponse = CursorPaginatedResponse <GymForReturnDto> .CreateFrom(gyms, mapper.Map <IEnumerable <GymForReturnDto> >, gymSearchParams);

            return(Ok(paginatedResponse));
        }
Exemplo n.º 16
0
        public async Task <ActionResult <CursorPaginatedResponse <BudgetDto> > > GetBudgetsForUserAsync([FromRoute] int userId, [FromQuery] CursorPaginationParameters searchParams)
        {
            if (!IsUserAuthorizedForResource(userId))
            {
                return(Unauthorized("You can only access your own budgets."));
            }

            var budgetParams = mapper.Map <BudgetQueryParameters>(searchParams);

            budgetParams.UserIds.Add(userId);

            var budgets = await budgetRepository.SearchAsync(budgetParams);

            var paginatedResponse = CursorPaginatedResponse <BudgetDto> .CreateFrom(budgets, mapper.Map <IEnumerable <BudgetDto> >, budgetParams);

            return(Ok(paginatedResponse));
        }
Exemplo n.º 17
0
        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 <ExpenseDto> > > GetExpensesForBudgetAsync(int id, [FromQuery] CursorPaginationParameters searchParams)
        {
            var budget = await budgetRepository.GetByIdAsync(id);

            if (budget == null)
            {
                return(NotFound($"No Budget with Id {id} found."));
            }

            if (!IsUserAuthorizedForResource(budget))
            {
                return(Unauthorized("You can only access your own budget."));
            }

            var expenses = await budgetRepository.GetExpensesForBudgetAsync(id, searchParams);

            var paginatedResponse = CursorPaginatedResponse <ExpenseDto> .CreateFrom(expenses, mapper.Map <IEnumerable <ExpenseDto> >, searchParams.IncludeNodes, searchParams.IncludeEdges);

            return(Ok(paginatedResponse));
        }
        public async Task <ActionResult <CursorPaginatedResponse <WorkoutInvitationForReturnDto> > > GetSentWorkoutInvitationsForUserAsync(int userId, [FromQuery] CursorPaginationParams searchParams, string status)
        {
            if (userId != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value))
            {
                return(Unauthorized());
            }

            var invSearchParams = new WorkoutInvitationSearchParams
            {
                First        = searchParams.First,
                After        = searchParams.After,
                Last         = searchParams.Last,
                Before       = searchParams.Before,
                IncludeTotal = searchParams.IncludeTotal,
                InviterId    = userId,
                Status       = status
            };

            var invitations = await workoutInvitationRepository.SearchAsync(invSearchParams);

            var paginatedResponse = CursorPaginatedResponse <WorkoutInvitationForReturnDto> .CreateFrom(invitations, mapper.Map <IEnumerable <WorkoutInvitationForReturnDto> >);

            return(Ok(paginatedResponse));
        }