public ActionResult <LessonDTO> BookNewLesson(Lesson lesson) { string userId = User?.Identity?.Name; if (string.IsNullOrEmpty(userId)) { return(Forbid()); } if (lesson.Duration == null || lesson.StudentId == null || lesson.LessonDate == null) { return(BadRequest("One or more required fields were not supplied.")); } Lesson bookedLesson = LessonService.BookNewLesson(lesson, int.Parse(userId)); LessonDTO dto = new LessonDTO(bookedLesson); return(Ok(dto)); }