Untitled
unknown
plain_text
a year ago
560 B
3
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