Exemplo n.º 1
0
        public async Task <GymClasses[]> getUserClasses(string username)
        {
            ClassRegister[] registerList = await registerRepository.getUserRegisters(username);

            if (registerList.Length == 0)
            {
                return(new GymClasses[0]);
            }

            GymClasses[] classList = new GymClasses[registerList.Length];

            for (int i = 0; i < registerList.Length; i++)
            {
                classList[i] = await getClassById(registerList[i].ClassIdForeignKey);
            }

            return(classList);
        }
Exemplo n.º 2
0
        public async Task <ActionResult <GymClassResponse[]> > getByUser(string username)
        {
            if (await userRepository.getUser(username) == null)
            {
                return(StatusCode(StatusCodes.Status404NotFound, "The specified user was not found!"));
            }

            ClassRegister[] registerList = await registerRepository.getUserRegisters(username, true);

            if (registerList.Length == 0)
            {
                return(Ok(new GymClassResponse[0]));
            }

            GymClassResponse[] classesReduced = new GymClassResponse[registerList.Length];

            for (int i = 0; i < registerList.Length; i++)
            {
                classesReduced[i] = ClassMappers.classModelToReducedModel(registerList[i].Class);
            }

            return(Ok(classesReduced));
        }