public IActionResult Put(int id, [FromBody] CourseToViewModel course)
        {
            if (!DbAccessUnit.Professors.Exists(course.ProfessorId))
            {
                return(NotFound("Invalid Professor ID"));
            }

            var courseFromDb = DbAccessUnit.Courses.Get(id);

            if (courseFromDb == null)
            {
                var courseToAdd = course.Adapt <Course>();
                DbAccessUnit.Courses.Add(courseToAdd);
                DbAccessUnit.Save();
                var courseToReturn = courseToAdd.Adapt <CourseViewModel>();
                return(CreatedAtRoute("GetCourse",
                                      new { id = courseToAdd.Id },
                                      courseToReturn));
            }

            course.Adapt(courseFromDb);
            DbAccessUnit.Save();

            return(NoContent());
        }
        public ActionResult <CourseViewModel> Post(CourseToViewModel course)
        {
            if (!DbAccessUnit.Professors.Exists(course.ProfessorId))
            {
                return(NotFound("Invalid Professor ID"));
            }
            var courseEntity = course.Adapt <Course>();

            DbAccessUnit.Courses.Add(courseEntity);
            DbAccessUnit.Save();

            var courseToReturn = courseEntity.Adapt <CourseViewModel>();

            return(CreatedAtRoute("GetCourse",
                                  new { id = courseEntity.Id },
                                  courseToReturn));
        }