コード例 #1
0
        public void Execute(OrderPlacedArgs args)
        {
            if (!_ecommerceSettings.RewardPointsEnabled)
            {
                return;
            }

            var order = args.Order;

            if (order.User == null)
            {
                return;
            }

            var rewardPointsAppliedAmount = order.RewardPointsAppliedAmount;
            var pointsToSpend             = GetPointsToSpend(rewardPointsAppliedAmount);

            if (pointsToSpend <= 0)
            {
                return;
            }

            _session.Transact(session => session.Save(new PointsSpent
            {
                Points = -pointsToSpend,
                User   = order.User,
                Order  = order,
            }));
        }
コード例 #2
0
        public void Execute(OrderPlacedArgs args)
        {
            _session.Transact(session =>
            {
                User currentUser = CurrentRequestData.CurrentUser;
                if (currentUser != null)
                {
                    var addresses = session.QueryOver<Address>().Where(address => address.User.Id == currentUser.Id).List();

                    var order = args.Order;
                    if (!addresses.Contains(order.BillingAddress, AddressComparison.Comparer))
                    {
                        var clone = order.BillingAddress.ToAddress(session, currentUser);
                        session.Save(clone);
                        addresses.Add(clone);
                    }
                    if (order.ShippingAddress != null && order.ShippingStatus != ShippingStatus.ShippingNotRequired &&
                        !addresses.Contains(order.ShippingAddress, AddressComparison.Comparer))
                    {
                        session.Save(order.ShippingAddress.ToAddress(session, currentUser));
                    }
                    if (string.IsNullOrEmpty(currentUser.FirstName) &&
                        string.IsNullOrEmpty(currentUser.LastName) &&
                        order.BillingAddress != null)
                    {
                        currentUser.FirstName = order.BillingAddress.FirstName;
                        currentUser.LastName = order.BillingAddress.LastName;
                        session.Save(currentUser);
                    }
                }
            });
        }
コード例 #3
0
        public void Execute(OrderPlacedArgs args)
        {
            _session.Transact(session =>
            {
                User currentUser = CurrentRequestData.CurrentUser;
                if (currentUser != null)
                {
                    var addresses = session.QueryOver <Address>().Where(address => address.User.Id == currentUser.Id).List();

                    var order = args.Order;
                    if (!addresses.Contains(order.BillingAddress, AddressComparison.Comparer))
                    {
                        var clone = order.BillingAddress.ToAddress(session, currentUser);
                        session.Save(clone);
                        addresses.Add(clone);
                    }
                    if (order.ShippingAddress != null && order.ShippingStatus != ShippingStatus.ShippingNotRequired &&
                        !addresses.Contains(order.ShippingAddress, AddressComparison.Comparer))
                    {
                        session.Save(order.ShippingAddress.ToAddress(session, currentUser));
                    }
                    if (string.IsNullOrEmpty(currentUser.FirstName) &&
                        string.IsNullOrEmpty(currentUser.LastName) &&
                        order.BillingAddress != null)
                    {
                        currentUser.FirstName = order.BillingAddress.FirstName;
                        currentUser.LastName  = order.BillingAddress.LastName;
                        session.Save(currentUser);
                    }
                }
            });
        }
コード例 #4
0
 public void Execute(OrderPlacedArgs args)
 {
     if (args.Order != null && args.Order.BillingAddress != null && args.Order.SalesChannel == EcommerceApp.DefaultSalesChannel)
     {
         var message =
             string.Format("A <a href='/Admin/Apps/Ecommerce/Order/Edit/{0}'>new order</a> has been placed by {1}.",
                 args.Order.Id, args.Order.BillingAddress.Name);
         _notificationPublisher.PublishNotification(message, PublishType.Both, NotificationType.AdminOnly);
     }
 }
コード例 #5
0
 public void Execute(OrderPlacedArgs args)
 {
     if (args.Order != null && args.Order.BillingAddress != null && args.Order.SalesChannel == EcommerceApp.DefaultSalesChannel)
     {
         var message =
             string.Format("A <a href='/Admin/Apps/Ecommerce/Order/Edit/{0}'>new order</a> has been placed by {1}.",
                           args.Order.Id, args.Order.BillingAddress.Name);
         _notificationPublisher.PublishNotification(message, PublishType.Both, NotificationType.AdminOnly);
     }
 }
コード例 #6
0
ファイル: UpdateStock.cs プロジェクト: neozhu/Ecommerce
 public void Execute(OrderPlacedArgs args)
 {
     _session.Transact(session =>
                       {
                           var order = args.Order;
                           foreach (var orderLine in
                                   order.OrderLines.Where(
                                       line => line.ProductVariant.TrackingPolicy == TrackingPolicy.Track))
                               {
                                   var productVariant = orderLine.ProductVariant;
                                   if (productVariant != null)
                                       productVariant.StockRemaining -= orderLine.Quantity;
                                   session.Update(productVariant);
                               }
                       });
 }
コード例 #7
0
        public void Execute(OrderPlacedArgs args)
        {
            if (!_ecommerceSettings.RewardPointsEnabled)
                return;

            var order = args.Order;

            if (order.User == null)
                return;

            var rewardPointsAppliedAmount = order.RewardPointsAppliedAmount;
            var pointsToSpend = GetPointsToSpend(rewardPointsAppliedAmount);
            if (pointsToSpend <= 0)
                return;

            _session.Transact(session => session.Save(new PointsSpent
            {
                Points = -pointsToSpend,
                User = order.User,
                Order = order,
            }));
        }
コード例 #8
0
ファイル: EmptyBasket.cs プロジェクト: neozhu/Ecommerce
 public void Execute(OrderPlacedArgs args)
 {
     _emptyBasket.Empty();
 }
コード例 #9
0
 public void Execute(OrderPlacedArgs args)
 {
     CurrentRequestData.OnEndRequest.Add(new ExecuteLuceneTasks());
 }
コード例 #10
0
 public void Execute(OrderPlacedArgs args)
 {
     var queuedMessage = _messageParser.GetMessage(args.Order);
     if (queuedMessage != null)
         _session.Transact(session => session.Save(queuedMessage));
 }