示例#1
0
        private EntryXml GetEntry(string categoryName, string exerciseName, string userId)
        {
            ExerciseXml exercise = GetExercise(categoryName, exerciseName);

            if (exercise.Entries == null)
            {
                exercise.Entries    = new EntryXml[1];
                exercise.Entries[0] = new EntryXml(userId);
                return(exercise.Entries[0]);
            }

            foreach (EntryXml entry in exercise.Entries)
            {
                if (entry.UID == userId)
                {
                    return(entry);
                }
            }

            EntryXml appendedEntry = new EntryXml(userId);

            EntryXml[] entries = new EntryXml[exercise.Entries.Length + 1];
            entries[entries.Length - 1] = appendedEntry;
            exercise.Entries.CopyTo(entries, 0);
            exercise.Entries = entries;

            return(appendedEntry);
        }
示例#2
0
        private ExerciseXml GetExercise(string categoryName, string exerciseName)
        {
            CategoryXml category = GetCategory(categoryName);

            if (category.Exercises == null)
            {
                category.Exercises    = new ExerciseXml[1];
                category.Exercises[0] = new ExerciseXml(exerciseName);
                return(category.Exercises[0]);
            }

            foreach (ExerciseXml exercise in category.Exercises)
            {
                if (exercise.Name == exerciseName)
                {
                    return(exercise);
                }
            }

            ExerciseXml appendedExercise = new ExerciseXml(exerciseName);

            ExerciseXml[] exercises = new ExerciseXml[category.Exercises.Length + 1];
            exercises[exercises.Length - 1] = appendedExercise;
            category.Exercises.CopyTo(exercises, 0);
            category.Exercises = exercises;

            return(appendedExercise);
        }