Ejemplo n.º 1
0
 internal static BookEntity ToBookEntity(this BookForCreate bookFroCreate)
 {
     return(new BookEntity
     {
         Description = bookFroCreate.Description,
         Title = bookFroCreate.Title
     });
 }
Ejemplo n.º 2
0
        public Task AddBookAsync(BookForCreate bookForCreate)
        {
            if (bookForCreate is null)
            {
                throw new ArgumentNullException(nameof(bookForCreate));
            }

            return(addBookAsync());

            async Task addBookAsync()
            {
                var bookEntity = bookForCreate.ToBookEntity();

                bookEntity.Id = Guid.NewGuid().ToString();

                await _repository.SaveAsync(bookEntity);
            }
        }