Esempio n. 1
0
        public static BasketWhitoutCheckOutId ClearBasket(IProduct _product, IBasket _basket, ResolveFieldContext <object> context)
        {
            string checkoutId = context.GetArgument <string>("checkoutId");
            Basket basket     = _basket.ClearBasket(checkoutId);

            return(ConvertBasketToBasketWithProductObjects.BasketConverter(_product, basket));
        }
Esempio n. 2
0
        public static BasketWithProductObjects GetBasketByCheckoutId(IProduct _product, IBasket _basket, ResolveFieldContext <object> context)
        {
            string checkoutId = context.GetArgument <string>("checkoutId");
            Basket basket     = _basket.GetBasketByCheckoutId(checkoutId);


            BasketWhitoutCheckOutId basketWhitoutCheckOutId = ConvertBasketToBasketWithProductObjects.BasketConverter(_product, basket);

            return(new BasketWithProductObjects(checkoutId, basketWhitoutCheckOutId.BasketItemsWhitProduct));
        }
        public static BasketWhitoutCheckOutId AddItemToBasket(IProduct _product, IBasket _basket, ResolveFieldContext <object> context)
        {
            try
            {
                string checkoutId = context.GetArgument <string>("checkoutId");
                int    productId  = context.GetArgument <int>("productId");
                Basket basket     = _basket.AddItemToBasket(checkoutId, productId);

                return(ConvertBasketToBasketWithProductObjects.BasketConverter(_product, basket));
            }
            catch (BusinessException ex)
            {
                context.Errors.Add(new ExecutionError(ex.Message));

                return(null);
            }
        }