public async Task <ActionResult> AssignMentorToLesson(AssignMentorToLessonDto ids) { var changedLesson = await _lessonService.AssignMentorToLessonAsync(ids); if (changedLesson == null) { return(StatusCode(422, "Lesson doesn't exist")); } return(Ok(changedLesson)); }
public async Task <Lesson> AssignMentorToLessonAsync(AssignMentorToLessonDto ids) { var mentorToAssign = await _unitOfWork.MentorRepository.GetMentorByAccountIdAsync(ids.MentorId); if (mentorToAssign == null) { throw new NullReferenceException(); } var foundLesson = await _unitOfWork.LessonRepository.GetByIdAsync(ids.LessonId); foundLesson.MentorId = ids.MentorId; await _unitOfWork.CommitAsync(); return(foundLesson); }