Ejemplo n.º 1
0
        public async Task <AddAuthorPayload> AddAuthorAsync(
            AddAuthorInput input,
            CancellationToken cancellationToken)
        {
            var author = new Author
            {
                Name = input.Name
            };

            _bookContext.Authors.Add(author);
            await _bookContext.SaveChangesAsync(cancellationToken);

            return(new AddAuthorPayload(author));
        }
Ejemplo n.º 2
0
        public async Task <AddAuthorPayload> AddAuthorAsync(
            AddAuthorInput input,
            [ScopedService] BookContext dbContext)
        {
            var author = new Author
            {
                Name = input.Name
            };

            dbContext.Authors.Add(author);
            await dbContext.SaveChangesAsync();

            return(new AddAuthorPayload(author));
        }