Ejemplo n.º 1
0
        public async Task <int> AddNewBook(BookModel model)
        {
            var book = new Books()
            {
                Author      = model.Author,
                CreatedOn   = DateTime.UtcNow,
                Description = model.Description,
                Title       = model.Title,
                Language    = model.Language,
                TotalPages  = model.TotalPages.HasValue ? model.TotalPages.Value : 0,
                UpdatedOn   = DateTime.UtcNow
            };

            await _context.Books.AddAsync(book);

            await _context.SaveChangesAsync();

            return(book.Id);
        }
 public async Task SaveAsync()
 {
     await _dbContext.SaveChangesAsync();
 }