public void CreateWorkOut(WorkOutVM wo)
        {
            var workout = new WorkOut
            {
                WorkOutId   = wo.Id,
                WorkOutName = wo.Name
            };

            if (workout.WorkOutId == 0)
            {
                _repo.Add(workout);
            }
            else
            {
                _repo.Update(workout);
            }

            foreach (var exercise in wo.Exercises)
            {
                var we = new WorkOutExercise();
                we.ExerciseId = exercise.ExerciseID;
                we.WorkOutId  = workout.WorkOutId;
                _repo.Add(we);
            }
        }
Exemple #2
0
 public void Post([FromBody] WorkOutVM workout)
 {
     if (ModelState.IsValid)
     {
         _service.CreateWorkOut(workout);
     }
     else
     {
         BadRequest();
     }
 }