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)); }
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); } }