public async Task <ActionResult> Index(CartPage currentPage) { var messages = string.Empty; if (TempData[Constant.Quote.RequestQuoteStatus] != null) { var requestQuote = (bool)TempData[Constant.Quote.RequestQuoteStatus]; if (requestQuote) { ViewBag.QuoteMessage = "Request quote successfully"; } else { ViewBag.ErrorMessage = "Request quote unsuccessfully"; } } if (CartWithValidationIssues.Cart != null && CartWithValidationIssues.ValidationIssues.Any()) { foreach (var item in CartWithValidationIssues.Cart.GetAllLineItems()) { messages = GetValidationMessages(item, CartWithValidationIssues.ValidationIssues); } } var viewModel = _cartViewModelFactory.CreateLargeCartViewModel(CartWithValidationIssues.Cart, currentPage); viewModel.Message = messages; var trackingResponse = await _recommendationService.TrackCart(HttpContext, CartWithValidationIssues.Cart); //viewModel.Recommendations = trackingResponse.GetCartRecommendations(_referenceConverter); return(View("LargeCart", viewModel)); }
public void ConfigureQueries(ObjectGraphType queryContext) { queryContext.Connection <ProductType>() .Name("products") .Argument <StringGraphType>("query", "The search query") .Resolve(ResolveQuickSearch); queryContext.Field <CartType>("cart", resolve: context => { ICart cart = _cartService.LoadCart(_cartService.DefaultCartName); return(_cartViewModelFactory.CreateLargeCartViewModel(cart)); }); }
public async Task <ActionResult> Index(CartPage currentPage) { var messages = string.Empty; if (CartWithValidationIssues.Cart != null && CartWithValidationIssues.ValidationIssues.Any()) { foreach (var item in CartWithValidationIssues.Cart.GetAllLineItems()) { messages = GetValidationMessages(item, CartWithValidationIssues.ValidationIssues); } } var viewModel = _cartViewModelFactory.CreateLargeCartViewModel(CartWithValidationIssues.Cart, currentPage); viewModel.Message = messages; var trackingResponse = await _recommendationService.TrackCart(HttpContext, CartWithValidationIssues.Cart); //viewModel.Recommendations = trackingResponse.GetCartRecommendations(_referenceConverter); return(View("LargeCart", viewModel)); }
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 }); }
public ActionResult LargeCart() { var viewModel = _cartViewModelFactory.CreateLargeCartViewModel(Cart); return(PartialView("LargeCart", viewModel)); }