/// <summary> /// Runs the processor. /// </summary> /// <param name="args">The arguments.</param> public virtual void Process([NotNull] PipelineArgs args) { Assert.ArgumentNotNull(args, "args"); object orderNumber = args.CustomData["orderNumber"]; Assert.IsNotNull(orderNumber, "OrderNumber cannot be null."); VisitorOrderManager orderRepository = Context.Entity.Resolve <VisitorOrderManager>(); Assert.IsNotNull(orderRepository, "OrderManager cannot be null."); string orderId = orderNumber.ToString(); Order order = orderRepository.GetAll().SingleOrDefault(o => (o != null) && (o.OrderId == orderId)); Assert.IsNotNull(order, "Order cannot be null."); OrderConfirmation orderConfirmation = Context.Entity.Resolve <OrderConfirmation>(); Assert.IsNotNull(orderConfirmation, "OrderConfirmation cannot be null."); Assert.IsNotNull(orderConfirmation.ConfirmationMessageBuilder, "OrderConfirmation.ConfirmationMessageBuilder cannot be null."); orderConfirmation.ConfirmationMessageBuilder.Order = order; orderConfirmation.Send(); }
/// <summary> /// Creates the specified order. /// </summary> /// <param name="orderSerialization">The order serialization.</param> /// <param name="args">The arguments.</param> public void Create(string orderSerialization, ServiceClientArgs args) { SiteContext site = Utils.GetExistingSiteContext(args); using (new SiteContextSwitcher(site)) { VisitorOrderManager orderRepository = Context.Entity.Resolve <VisitorOrderManager>(); var settings = new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore, MissingMemberHandling = MissingMemberHandling.Ignore, PreserveReferencesHandling = PreserveReferencesHandling.Objects }; settings.Error += this.DeserializationErrorHandler; Order order = JsonConvert.DeserializeObject <Order>(orderSerialization, settings); orderRepository.Create(order); PipelineArgs pipelineArgs = new PipelineArgs(); pipelineArgs.CustomData.Add("orderNumber", order.OrderId); CorePipeline.Run("orderCreated", pipelineArgs); } }
/// <summary> /// Initializes a new instance of the <see cref="TransientOrderManager" /> class. /// </summary> /// <param name="innerRepository">The inner repository.</param> /// <param name="orderConverter">The order converter.</param> /// <param name="orderIdGenerator">The order id generator.</param> /// <param name="customerManager">The customer manager.</param> /// <param name="entityHelper">The entity helper.</param> /// <param name="transactionData">The transaction data.</param> /// <param name="shopContext">The shop context.</param> public TransientOrderManager(VisitorOrderManager innerRepository, TransientOrderConverter orderConverter, OrderIDGenerator orderIdGenerator, ICustomerManager <CustomerInfo> customerManager, EntityHelper entityHelper, ITransactionData transactionData, ShopContext shopContext) { this.innerRepository = innerRepository; this.orderConverter = orderConverter; this.orderIDGenerator = orderIdGenerator; this.customerManager = customerManager; this.entityHelper = entityHelper; this.transactionData = transactionData; this.shopContext = shopContext; }
/// <summary> /// Cancels the order. /// </summary> /// <param name="orderNumber">The order number.</param> /// <param name="args">The arguments.</param> public void CancelOrder(string orderNumber, ServiceClientArgs args) { SiteContext site = Utils.GetExistingSiteContext(args); using (new SiteContextSwitcher(site)) { VisitorOrderManager orderManager = Context.Entity.Resolve <VisitorOrderManager>(); VisitorOrderProcessorBase visitorOrderProcessor = Context.Entity.Resolve <VisitorOrderProcessorBase>(); Utils.SetCustomerId(args, orderManager); Order order = orderManager.GetAll().FirstOrDefault(o => o.OrderId == orderNumber); Assert.IsNotNull(order, "order cannot be null."); visitorOrderProcessor.CancelOrder(order); } }
/// <summary> /// Gets all orders. /// </summary> /// <param name="filterExpression">The ExpressionSerializer expression.</param> /// <param name="args">The arguments.</param> /// <returns> /// The all orders. /// </returns> public string GetAll(string filterExpression, ServiceClientArgs args) { SiteContext site = Utils.GetExistingSiteContext(args); using (new SiteContextSwitcher(site)) { VisitorOrderManager orderRepository = Context.Entity.Resolve <VisitorOrderManager>(); Utils.SetCustomerId(args, orderRepository); var tempResult = orderRepository.GetAll(); object rawResult = this.ExpressionSerializer.ApplyExpressionAsFilter(tempResult, filterExpression); var settings = new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore, MissingMemberHandling = MissingMemberHandling.Ignore, PreserveReferencesHandling = PreserveReferencesHandling.Objects }; return(JsonConvert.SerializeObject(rawResult, Formatting.None, settings)); } }