Untitled
Anonymous
plain_text
02/29/2024 6:26 AM
668 B
14
Indexable
public async Task<IActionResult> DeleteAllProductsFromCart(string email)
{
var cartsToDelete = await _context.Carts.Where(c => c.EmailId == email).ToListAsync();
if (cartsToDelete == null || !cartsToDelete.Any())
{
return NotFound(); // Return 404 if no carts are found
}
_context.Carts.RemoveRange(cartsToDelete);
await _context.SaveChangesAsync();
return Ok(cartsToDelete); // Return 200 with the list of deleted carts
}Editor is loading...
Leave a Comment