public async Task <IActionResult> Delete(int id)
        {
            var catalogItem = await _db.CatalogItems.FirstOrDefaultAsync(c => c.Id == id);

            _db.Remove(catalogItem);
            var success = (await _db.SaveChangesAsync()) > 0;

            return(new JsonResult(success));
        }
        public async Task <IActionResult> DeleteProduct(int id)
        {
            var catalogItem = await catalogContext.CatalogItems.SingleOrDefaultAsync(w => w.Id == id);

            if (catalogItem == null)
            {
                return(NotFound());
            }

            catalogContext.Remove(catalogItem);
            await catalogContext.SaveChangesAsync();

            return(NoContent());
        }
Ejemplo n.º 3
0
 public void Delete <T>(T entity) where T : class
 {
     _context.Remove(entity);
 }
 /// <inheritdoc />
 public bool Delete(TDomain domain)
 {
     Context.Remove(domain);
     return(Context.SaveChanges() > 0);
 }