コード例 #1
0
        public void DeleteExercise(Exercise exerciseToDelete)
        {
            Exercise exToDelete = GetExerciseById(exerciseToDelete.ExerciseId);
            if (exToDelete == null) throw new Exception("Exercise to delete not found - from DeleteExercise");

            Exercises.Remove(exToDelete);
            db.Exercises.DeleteOnSubmit(exToDelete);

            db.ExTrDayConnectors.DeleteAllOnSubmit(
                db.ExTrDayConnectors.Where(x =>
                    x._exerciseId == exerciseToDelete.ExerciseId));

            Deployment.Current.Dispatcher.BeginInvoke(() => db.SubmitChanges()); 
        }
コード例 #2
0
        public void AddNewExercise(Exercise newExercise)
        {
            int index = 0;

            foreach (Exercise exercise in Exercises.ToList())
            {
                if (newExercise.ExerciseName.CompareTo(exercise.ExerciseName) <= 0) break;

                ++index;
            }

            Exercises.Insert(index, newExercise);

            db.Exercises.InsertOnSubmit(newExercise);
            Deployment.Current.Dispatcher.BeginInvoke(() => db.SubmitChanges()); 
        }
コード例 #3
0
        public void UpdateExercise(Exercise exerciseToUpdate)
        {
            Exercise exToUpdate = db.Exercises.FirstOrDefault(ex => ex.ExerciseId == exerciseToUpdate.ExerciseId);
            if (exToUpdate == null) throw new Exception("Exercise to edit not found - from UpdateExercise");

            if (exToUpdate.ExerciseName != exerciseToUpdate.ExerciseName)
            {
                Exercises.Remove(exToUpdate);

                int index = 0;

                foreach (Exercise exercise in Exercises.ToList())
                {
                    if (exerciseToUpdate.ExerciseName.CompareTo(exercise.ExerciseName) <= 0) break;

                    ++index;
                }

                Exercises.Insert(index, exToUpdate);
            }

            exToUpdate.AmountOfReps = exerciseToUpdate.AmountOfReps;
            exToUpdate.AmountOfSets = exerciseToUpdate.AmountOfSets;
            exToUpdate.DurationInMinutes = exerciseToUpdate.DurationInMinutes;
            exToUpdate.ExerciseName = exerciseToUpdate.ExerciseName;
            exToUpdate.ImageUri = exerciseToUpdate.ImageUri;
            exToUpdate.Intensity = exerciseToUpdate.Intensity;
            exToUpdate.OtherInfo = exerciseToUpdate.OtherInfo;

            Deployment.Current.Dispatcher.BeginInvoke(() => db.SubmitChanges()); 
        }