/// <summary>
        /// Converts shopping cart as order.
        /// </summary>
        /// <returns>Order.</returns>
        public virtual Order AsOrder()
        {
            var customerName = CustomerSession.CustomerName;

            //If user is anonymous take name from billing address
            if (string.IsNullOrEmpty(customerName))
            {
                var billingAddress = Cart.OrderAddresses.FirstOrDefault(a => a.OrderAddressId == Cart.AddressId);
                if (billingAddress != null)
                {
                    customerName = string.Format("{0} {1}", billingAddress.FirstName, billingAddress.LastName);
                }
            }

            var order = new Order();
            order.InjectFrom<CloneInjection>(Cart);
            order.CustomerName = customerName;
            order.Status = "Pending";
            order.Name = "Default";
            order.TrackingNumber = SequencesService.GetNext(typeof(Order).FullName);

            foreach (var newOf in order.OrderForms)
            {
                newOf.Name = "Default";
                newOf.OrderFormPropertyValues.Add(new OrderFormPropertyValue() { ShortTextValue = CustomerSession.Language, Name = "Language" });
                if (!string.IsNullOrEmpty(CustomerSession.CsrUsername))
                {
                    //Add order form property CSR username is saved in the order form property called "Purchased By CSR"
                    newOf.OrderFormPropertyValues.Add(new OrderFormPropertyValue() { ShortTextValue = CustomerSession.CsrUsername, Name = "Purchased By CSR" });
                }
            }

            return order;
        }
        protected override void Execute(CodeActivityContext context)
        {
            base.Execute(context);

            if (ServiceLocator == null)
                return;

            if (CurrentOrderGroup == null || CurrentOrderGroup.OrderForms.Count == 0)
                return;

            var customerName = CustomerSessionService.CustomerSession.CustomerName;

            //If user is anonymous take name from billing address
            if (string.IsNullOrEmpty(customerName))
            {
                var billingAddress = CurrentOrderGroup.OrderAddresses.FirstOrDefault(a => a.OrderAddressId == CurrentOrderGroup.AddressId);
                if (billingAddress != null)
                {
                    customerName = string.Format("{0} {1}", billingAddress.FirstName, billingAddress.LastName);
                }
            }

            var order = new Order();
            order.InjectFrom<CloneInjection>(CurrentOrderGroup);
            order.CustomerName = customerName;
            order.Status = "Pending";
            order.Name = "Default";
            order.TrackingNumber = SequencesClient.GenerateNext(typeof(Order).FullName);

            foreach (var newOf in order.OrderForms)
            {
                newOf.Name = "Default";
                if (!string.IsNullOrEmpty(CustomerSessionService.CustomerSession.CsrUsername))
                {
                    //Add order form property CSR username is saved in the order form property called "Purchased By CSR"
                    newOf.OrderFormPropertyValues.Add(new OrderFormPropertyValue() { ShortTextValue = CustomerSessionService.CustomerSession.CsrUsername, Name = "Purchased By CSR" });
                }
            }
            var cart = OrderRepository.ShoppingCarts.FirstOrDefault(c => c.OrderGroupId == CurrentOrderGroup.OrderGroupId);
            if (cart != null)
            {
                OrderRepository.Remove(cart);
            }
            OrderRepository.Add(order);
            OrderRepository.UnitOfWork.Commit();
        }