Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
398 B
1
Indexable
Never
public async Task<List<Cart>> DeleteAllProductsFromCart(string email)
{
    List<Cart> cartsToDelete = await _context.Carts.Where(c => c.EmailId == email).ToListAsync();
    
    if (cartsToDelete != null && cartsToDelete.Any())
    {
        _context.Carts.RemoveRange(cartsToDelete);
        await _context.SaveChangesAsync();
        
        return cartsToDelete;
    }
    
    return null;
}
Leave a Comment