Пример #1
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));
        }
        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));
        }
Пример #3
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));
        }
Пример #4
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));
        }
Пример #5
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));
        }
        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));
        }
Пример #7
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));
        }
Пример #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));
        }
Пример #9
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));
        }
Пример #10
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));
        }
Пример #11
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));
        }
Пример #12
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));
        }
Пример #14
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));
        }
Пример #15
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));
        }
Пример #16
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));
        }