Exemplo n.º 1
0
        public async Task <DeleteTaskResponse> Delete(Guid id)
        {
            var oldOne = await _taskQuery.GetByIdAsync(id);

            if (oldOne == null)
            {
                throw new CoreException($"Could not delete item #{id}.");
            }

            var result = await _taskRepository.DeleteAsync(oldOne);

            return(new DeleteTaskResponse());
        }
        public async Task <IActionResult> Delete(Guid id)
        {
            var post = await _postRepo.GetByIdAsync(id);

            if (post == null)
            {
                return(NotFound());
            }
            await _postRepo.DeleteAsync(post);

            await _postMessageHubContext.Clients.All.InvokeAsync("DeletePostSuccess", id);

            return(new NoContentResult());
        }
Exemplo n.º 3
0
        public async Task <bool> RemoveItemInCartAsync(Guid cartId, Guid productId)
        {
            var cart = await GetCart(cartId);

            cart = await InitCart(cart);

            var cartItem = cart.CartItems.FirstOrDefault(x => x.Product.ProductId == productId);

            if (cartItem == null)
            {
                throw new Exception($"Could not find CartItem {cartItem.Id}");
            }

            cart = cart.RemoveCartItem(cartItem.Id);
            var isSucceed = await _mutateRepository.UpdateAsync(cart) != null;

            await _cartItemMutateRepository.DeleteAsync(cartItem);

            cart = PriceCalculatorContext.Execute(cart);

            return(isSucceed);
        }