public async Task <IActionResult> Delete(int id, CancellationToken cancellationToken) { var category = await _context.Categories.FirstOrDefaultAsync(p => p.Id == id, cancellationToken); if (category == null) { return(NotFound()); } _context.Remove(category); await _context.SaveChangesAsync(cancellationToken); return(Ok()); }
public async Task <IActionResult> Delete(int id, CancellationToken cancellationToken = default(CancellationToken)) { var product = await _context.Products.FirstOrDefaultAsync(p => p.Id == id, cancellationToken); if (product == null) { return(NotFound()); } _context.Remove(product); await _context.SaveChangesAsync(cancellationToken); return(Ok()); }