Ejemplo n.º 1
0
        public static GymClassResponse[] classModelToReducedModel(GymClasses[] sources)
        {
            GymClassResponse[] targets = new GymClassResponse[sources.Length];

            for (int i = 0; i < sources.Length; i++)
            {
                targets[i] = classModelToReducedModel(sources[i]);
            }

            return(targets);
        }
Ejemplo n.º 2
0
        public async Task <ActionResult <GymClassResponse> > getSpecificClass(int classid)
        {
            GymClasses targetClass = await classRepository.getClassById(classid);

            if (targetClass == null)
            {
                return(StatusCode(StatusCodes.Status404NotFound, "Specified class was not found!"));
            }

            GymClassResponse convertedObject = ClassMappers.classModelToReducedModel(targetClass);

            return(Ok(convertedObject));
        }
Ejemplo n.º 3
0
        public static GymClasses reducedClassToClassModel(GymClassResponse source)
        {
            GymClasses target = new GymClasses();

            target.ClassId            = source.ClassId;
            target.GymIdForeignKey    = source.GymId;
            target.InstructorUsername = source.Instructor;
            target.Name            = source.Name;
            target.Description     = source.Description;
            target.Day             = source.Day;
            target.StartTime       = source.StartTime;
            target.EndTime         = source.EndTime;
            target.MaxCapacity     = source.MaxCapacity;
            target.CurrentStudents = source.CurrentStudents;
            target.Cancelled       = source.Cancelled;

            return(target);
        }
Ejemplo n.º 4
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));
        }