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); }
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)); }
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); }
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)); }