public async Task RemoveAsync(Data.Order order) { foreach (var item in order.OrderItems) { var comic = await _context.ComicBooks.FindAsync(item.ComicBookId); if (comic == null) { throw new NullReferenceException("Invalid comic book Id"); } comic.Quantity = comic.Quantity + item.Quantity; _context.Update(comic); } _context.RemoveRange(order.OrderItems); _context.Remove(order); await _context.SaveChangesAsync(); }
public Task DeleteAsync(Data.ComicBook comic) { _context.RemoveRange(comic.ComicBookArtists); _context.Remove(comic); return(_context.SaveChangesAsync()); }