Untitled
unknown
plain_text
2 years ago
501 B
7
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