public async Task RemoveWishlistItem(int wishlistItemId, CancellationToken cancellationToken = default)
        {
            WishlistItem item = await _context.WishlistItems
                                .SingleOrDefaultAsync(wi => wi.WishlistItemId == wishlistItemId, cancellationToken);

            _context.Remove(item);
            await _context.SaveChangesAsync(cancellationToken);
        }
Exemple #2
0
        public async Task RemoveCartItem(int cartItemId, CancellationToken cancellationToken = default)
        {
            CartItem item = await _context.CartItems
                            .SingleOrDefaultAsync(ci => ci.CartItemId == cartItemId, cancellationToken);

            _context.Remove(item);
            await _context.SaveChangesAsync(cancellationToken);
        }
        public Product DeleteProduct(int id)
        {
            var productRemoved = _ctx.Remove(new Product {
                ProductId = id
            }).Entity;

            _ctx.SaveChanges();
            return(productRemoved);
        }
        public Order DeleteOrder(int id)
        {
            var orderRemoved = _ctx.Remove(new Order {
                OrderId = id
            }).Entity;

            _ctx.SaveChanges();
            return(orderRemoved);
        }
        public IActionResult Delete(int id)
        {
            Item dbItem = _context.Items.SingleOrDefault(u => u.Id == id);

            if (dbItem == null)
            {
                return(new NotFoundResult());
            }

            _context.Remove(dbItem);
            return(new NoContentResult());
        }
 public ActionResult AdminDeleteUser(int Id)
 {
     if (_context.Users.Find(Id) != null)
     {
         var UserInfo = (from u in _context.Users
                         where Id == u.Id
                         select u).ToArray();
         _context.Remove(UserInfo[0]);
         _context.SaveChanges();
         return(Ok());
     }
     return(NotFound());
 }
        public IActionResult Delete(int id)
        {
            if (!AuthService.ActionAuthorized(AuthUser, id))
            {
                return(new ForbidResult());
            }

            Order dbOrder = _context.Orders.SingleOrDefault(o => o.Id == id);

            if (dbOrder == null)
            {
                return(new NotFoundResult());
            }

            _context.Remove(dbOrder);
            return(new NoContentResult());
        }
Exemple #8
0
        public IActionResult Delete(int id)
        {
            if (!AuthService.ActionAuthorized(AuthUser, id))
            {
                return(new ForbidResult());
            }

            CartItem dbCartItem = _context.CartItems.SingleOrDefault(u => u.Id == id);

            if (dbCartItem == null)
            {
                return(new NotFoundResult());
            }

            _context.Remove(dbCartItem);

            return(new NoContentResult());
        }
 public Task DeleteAsync(Order order)
 {
     _dbContext.Remove(order);
     return(_dbContext.SaveChangesAsync());
 }