/// <summary>
        /// Creates a new workout based on the previous workout.
        /// </summary>
        /// <param name="previousWorkout">The most recent workout done by the user.</param>
        /// <returns></returns>
        private Workout CreateWorkout(Workout previousWorkout)
        {
            Workout workout = new Workout();
            workout.Activities = new List<Activity>();
            workout.Date = DateTime.UtcNow;
            workout.IsComplete = false;

            // Squat is in both workout routines.
            Activity previousSquat = this.activityManager.GetMostRecentActivity(ActivityName.Squat);
            int squatWeight = previousSquat.Weight;

            if (!previousSquat.IsFailure)
            {
                squatWeight += 5;
            }

            workout.AddActivity(new Squat(squatWeight));

            // Add other activities to workout based on routine.
            // Routines alternate between A and B.
            if (previousWorkout.Routine == RoutineName.A)
            {
                workout.Routine = RoutineName.B;

                Activity previousOverheadPress = this.activityManager.GetMostRecentActivity(ActivityName.OverheadPress);
                int overheadPressWeight = previousOverheadPress.Weight;

                if (!previousOverheadPress.IsFailure)
                {
                    overheadPressWeight += 5;
                }

                workout.AddActivity(new OverheadPress(overheadPressWeight));

                Activity previousDeadlift = this.activityManager.GetMostRecentActivity(ActivityName.Deadlift);
                int deadliftWeight = previousDeadlift.Weight;

                if (!previousDeadlift.IsFailure)
                {
                    deadliftWeight += 10;
                }

                workout.AddActivity(new Deadlift(deadliftWeight));
            }
            else
            {
                workout.Routine = RoutineName.A;

                Activity previousBenchPress = this.activityManager.GetMostRecentActivity(ActivityName.BenchPress);
                int benchPressWeight = previousBenchPress.Weight;

                if (!previousBenchPress.IsFailure)
                {
                    benchPressWeight += 5;
                }

                workout.AddActivity(new BenchPress(benchPressWeight));
            }

            return workout;
        }
 /// <summary>
 /// Saves or updates the specified workout.
 /// </summary>
 /// <param name="workout">Workout to save or update.</param>
 public void Save(Workout workout)
 {
     using (ISession session = NHibernateHelper.GetCurrentSession())
     using (ITransaction transaction = session.BeginTransaction())
     {
         session.SaveOrUpdate(workout);
         transaction.Commit();
     }
 }