Untitled

 avatar
unknown
plain_text
a year ago
501 B
5
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