Untitled
unknown
plain_text
2 years ago
560 B
4
Indexable
using System.Linq;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
public async Task<List<Cart>> DeleteAllProductsFromCart(string email)
{
var cartsToDelete = await _context.Carts.Where(c => c.EmailId == email).ToListAsync();
if (cartsToDelete == null || !cartsToDelete.Any())
{
return null; // Return null or throw an exception if no carts are found
}
_context.Carts.RemoveRange(cartsToDelete);
await _context.SaveChangesAsync();
return cartsToDelete; // Return the list of carts that were deleted
}
Editor is loading...
Leave a Comment