public void AddNewWorkoutNoExercisesTest()
        {
            SaveWorkoutViewModel model = new SaveWorkoutViewModel();
            model.EntryDate = DateTime.Now;

            ExerciseController controller = new ExerciseController(exerciseRepositoryMock.Object, workoutRepositoryMock.Object);
            var results = controller.Post(model) as HttpResponseMessage;

            Assert.IsNotNull(results);
            Assert.AreEqual(HttpStatusCode.BadRequest, results.StatusCode);
            Assert.AreEqual("no exercises present", results.ReasonPhrase);
        }
 public HttpResponseMessage Post(SaveWorkoutViewModel value)
 {
     //TODO: move to validation logic
     if (value == null)
         return new HttpResponseMessage(System.Net.HttpStatusCode.BadRequest) { ReasonPhrase = "no valid request content present" };
     if(value.EntryDate == null || value.EntryDate == DateTime.MinValue || value.EntryDate == DateTime.MaxValue)
         return new HttpResponseMessage(System.Net.HttpStatusCode.BadRequest) { ReasonPhrase = "no valid date present" };
     if (value.Exercises == null || value.Exercises.Count == 0)
         return new HttpResponseMessage(System.Net.HttpStatusCode.BadRequest) { ReasonPhrase = "no exercises present" };
     Workout workout = new Workout()
     {
         ExerciseEntries = new List<ExerciseEntry>(),
         WorkoutDate = value.EntryDate.Date
     };
     foreach (SaveExerciseViewModel saveExerciseViewModel in value.Exercises)
     {
         workout.ExerciseEntries.Add(AutoMapper.Mapper.Map<ExerciseEntry>(saveExerciseViewModel));
     }
     if (workoutFactory.SaveWorkout(workout, workoutRepository))
         return new HttpResponseMessage(System.Net.HttpStatusCode.Created);
     else
         return new HttpResponseMessage(System.Net.HttpStatusCode.BadRequest) { ReasonPhrase = "unable to save workout" };
 }