public override object MutateAndGetPayload(MutationInputs inputs, ResolveFieldContext <object> context) { var cart = _cartService.LoadOrCreateCart(_cartService.DefaultCartName); AddToCartResult result = _cartService.AddToCart(cart, inputs.Get <string>("code"), inputs.Get <decimal>("quantity", 1m)); if (!result.EntriesAddedToCart) { context.Errors.AddRange(result.ValidationMessages.Select(m => new ExecutionError(m))); return(null); } _orderRepository.Save(cart); _recommendationService.TrackCartAsync(_httpContextBase.Invoke()).Wait(); LargeCartViewModel largeCartViewModel = _cartViewModelFactory.CreateLargeCartViewModel(cart); return(new { Cart = largeCartViewModel }); }
public override object MutateAndGetPayload(MutationInputs inputs, ResolveFieldContext <object> context) { ICart cart = _cartService.LoadCart(_cartService.DefaultCartName); _cartService.ChangeCartItem( cart, inputs.Get <int>("shipmentId"), inputs.Get <string>("code"), inputs.Get <decimal>("quantity"), inputs.Get <string>("size"), inputs.Get <string>("newSize"), inputs.Get <string>("displayName")); _orderRepository.Save(cart); _recommendationService.TrackCartAsync(_httpContextBase.Invoke()).Wait(); LargeCartViewModel largeCartViewModel = _cartViewModelFactory.CreateLargeCartViewModel(cart); return(new { Cart = largeCartViewModel }); }