public async Task <ActionResult> Delete(Guid id) { var existingProduct = await _dbContext.Products.FindAsync(id); if (existingProduct is null) { return(NotFound()); } _dbContext.Remove(existingProduct); await _dbContext.SaveChangesAsync(); return(NoContent()); }
public async Task <ActionResult <Product> > Delete(int id) { var product = await _productsDbContext.Products.FindAsync(id); if (product == null) { return(NotFound()); } _productsDbContext.Remove(product); await _productsDbContext.SaveChangesAsync(); return(Ok(product)); }
public async void DeleteList(List <T> list) { try { foreach (var record in list) { _context.Remove(record); } await _context.SaveChangesAsync(); } catch (Exception) { throw; } }
/// <summary> /// Delete product from database /// </summary> /// <param name="id"></param> /// <returns>True if successful, else false</returns> public async Task <bool> DeleteProductAsync(Guid id) { var product = _context.Product.Find(id); if (product != null) { try { _context.Remove(product); await _context.SaveChangesAsync(); return(true); } catch (Exception) { // _logger.LogInformation("DeleteProductAsync Exeption", ex.Message); return(false); } } return(false); }
public void DeleteWorkStock(WorkStock workStock) { context.Remove(workStock); context.SaveChanges(); }
public void RemoveProduct(Product product) { _context.Remove(product); }