Exemplo n.º 1
0
        public async Task RemoveOrderItemAsync(Guid orderItemId, CancellationToken cancellationToken = default)
        {
            using (ShoppingCartDbContext context = _dbContextFactory())
            {
                OrderItemEntity orderItem = context.OrderItems.SingleOrDefault(a => a.Id == orderItemId);

                if (orderItem == null)
                {
                    throw new OrderItemNotFoundException($"OrderItem with ID {orderItemId} not found");
                }

                context.Remove(orderItem);

                await context.SaveChangesAsync(cancellationToken);
            }
        }
Exemplo n.º 2
0
 public Boolean RemoveUser(string userName)
 {
     try
     {
         if (userName != null)
         {
             User user = _shoppingCartDbContext.Users.FirstOrDefault(u => u.UserName == userName);
             _shoppingCartDbContext.Remove(user);
             _shoppingCartDbContext.SaveChanges();
             return(true);
         }
         return(false);
     }
     catch
     {
         throw;
     }
 }
 public void DeleteProduct(Guid id)
 {
     _context.Remove(GetProduct(id));
     _context.SaveChanges();
 }