public async Task <CourseDto> UpdateCourseAsync(Guid courseId, CourseUpdateRequest courseRequest) { if (courseId == Guid.Empty) { throw new ArgumentNullException(nameof(courseId)); } CourseEntity course = await _context.Courses.FirstOrDefaultAsync(x => x.Id == courseId); if (course == null) { return(null); } courseRequest.ToUpdateEntity(ref course); await _context.SaveChangesAsync(); return(course.ToDto()); }
public async Task <CourseDto> GetAuthorsCourseAsync(Guid authorId, Guid courseId) { if (authorId == Guid.Empty) { throw new ArgumentNullException(nameof(authorId)); } if (courseId == Guid.Empty) { throw new ArgumentNullException(nameof(courseId)); } if (!AuthorExists(authorId)) { return(null); } CourseEntity course = await _context.Courses .Where(c => c.AuthorId == authorId && c.Id == courseId).FirstOrDefaultAsync(); return(course.ToDto()); }