public async Task DeleteAsync(BookItems bookItems) { var entity = await _context.BookItems.SingleOrDefaultAsync(e => e.Id == bookItems.Id); _context.BookItems.Remove(entity); await _context.SaveChangesAsync(); }
public async Task EditAsync(BookItems bookItems) { var entity = await _context.BookItems.SingleOrDefaultAsync(e => e.Id == bookItems.Id); entity.Id = bookItems.Id; entity.Name = bookItems.Name; entity.Popular = bookItems.Popular; entity.Price = bookItems.Price; entity.Author = bookItems.Author; _context.BookItems.Update(entity); await _context.SaveChangesAsync(); }
public async Task <BookItems> AddItemsAsync(BookItems book) { var entity = new Book { Id = book.Id, Author = book.Author, Name = book.Name, Popular = book.Popular, Price = book.Price }; await _context.BookItems.AddAsync(entity); await _context.SaveChangesAsync(); book.Id = entity.Id; return(book); }