Пример #1
0
        public async Task AddAuthorAsync(CreateAuthorRequest author)
        {
            if (author == null)
            {
                throw new ArgumentNullException(nameof(author));
            }

            author.Id = Guid.NewGuid();

            _context.Authors.Add(author.ToEntity());

            await _context.SaveChangesAsync();
        }
Пример #2
0
        public async Task AddCourseAsync(Guid authorId, CreateCourseRequest course)
        {
            if (authorId == Guid.Empty)
            {
                throw new ArgumentNullException(nameof(authorId));
            }

            if (course == null)
            {
                throw new ArgumentNullException(nameof(course));
            }

            course.AuthorId = authorId;

            _context.Courses.Add(course.ToEntity());
            await _context.SaveChangesAsync();
        }