示例#1
0
 public OrderModel(Order order, Customer customer)
 {
     Id = order.Id;
     CustomerFirstName = customer.FirstName;
     CustomerLastName = customer.LastName;
     Total = order.Total;
     CreatedAtUtc = order.CreatedAtUtc;
     Status = order.Status;
     ProcessingStatus = order.ProcessingStatus;
 }
示例#2
0
 public bool SaveOrder(Order order)
 {
     try
     {
         _orderService.Save(order);
         return true;
     }
     catch
     {
         return false;
     }
 }
示例#3
0
        public void ChangeStatus(Order order, OrderStatus newStatus)
        {
            if (order.Status != newStatus)
            {
                var oldStatus = order.Status;
                order.Status = newStatus;

                _orderRepository.Database.SaveChanges();

                Event.Raise(new OrderStatusChanged(order, oldStatus, newStatus), _instance);
            }
        }
示例#4
0
        public void AcceptPayment(Order order, Payment payment)
        {
            Require.NotNull(payment, "payment");
            Require.That(payment.Status == PaymentStatus.Success, "payment", "Can only accept succeeded payment.");

            order.TotalPaid += payment.Amount;

            order.Total += payment.PaymentMethodCost;
            order.PaymentMethodCost += payment.PaymentMethodCost;

            _orderRepository.Database.SaveChanges();

            if (order.TotalPaid >= order.Total)
            {
                ChangeStatus(order, OrderStatus.Paid);
            }
        }
示例#5
0
 public OrderCreated(Order order)
     : base(order, null, OrderStatus.Created)
 {
     OrderId = order.Id;
 }
示例#6
0
 public bool SaveOrder(Order order)
 {
     return Put<bool>(null, order);
 }
示例#7
0
 public override bool CanExecute(Order order, CommerceInstance instance)
 {
     return order.Status == OrderStatus.Paid && order.ProcessingStatus != "Approved";
 }
示例#8
0
        public ActionResult Create(int? id, int? page, int? pageSize)
        {
            Order order = null;
            if (id.HasValue && id.Value > 0)
                order = _orderService.GetById(id.Value);
            else
            {
                order = new Order();
                order.CreatedAtUtc = DateTime.Now;
            }
            if (Request.UrlReferrer != null && Request.UrlReferrer.LocalPath.ToLower() == "/commerce/order/selectproduct")
            {
                order = Session["TempOrder"] as Order;
            }

            var customers = _customerService.Query().OrderByDescending(x => x.Id).ToPagedList(page, pageSize);
            ViewBag.Customers = customers;

            if (order.CustomerId > 0)
            {
                var customer = _customerService.GetById(order.CustomerId);
                TempData["Message"] = string.Format("Current Order: {0} {1} {2}", customer.FirstName, customer.MiddleName, customer.LastName);
            }
            Session["TempOrder"] = order;
            ViewBag.Return = "/Commerce/Order?siteName=" + Request.QueryString["siteName"] + "&commerceName=" + Request.QueryString["commerceName"];
            return View(order);
        }
示例#9
0
        public ActionResult Delete(Order[] model)
        {
            var data = new JsonResultData(ModelState);

            data.RunWithTry(_ =>
            {
                foreach (var obj in model)
                {
                    var order = _orderService.GetById(obj.Id, false);
                    _orderService.Delete(order);
                }
                data.ReloadPage = true;
            });

            return Json(data);
        }
示例#10
0
        public Order CreateFromCart(ShoppingCart cart, ShoppingContext context)
        {
            Require.NotNull(cart, "cart");
            Require.NotNull(cart.Customer, "cart.Customer", "Cannot create order from guest cart. Login is required.");
            Require.NotNull(cart.ShippingAddress, "cart.ShippingAddress", "Shipping address is required.");
            Require.That(cart.Items.Count > 0, "cart.Items", "Cannot create order from an empty cart.");

            // Recalculate price
            var pricingContext = new ShoppingCartService(_instance).CalculatePrice(cart, context);

            var order = new Order();
            order.ShoppingCartId = cart.Id;
            order.CustomerId = cart.Customer.Id;
            order.Coupon = cart.CouponCode;

            foreach (var item in pricingContext.Items)
            {
                var cartItem = cart.Items.FirstOrDefault(i => i.Id == item.ItemId);

                var orderItem = OrderItem.CreateFrom(cartItem, item.UnitPrice);
                orderItem.UnitPrice = item.UnitPrice;
                orderItem.Discount = item.Discount;
                orderItem.Subtotal = item.Subtotal;
                orderItem.Total = item.Subtotal - item.Discount;

                order.OrderItems.Add(orderItem);
            }

            order.ShippingAddress = OrderAddress.CreateFrom(cart.ShippingAddress);

            if (cart.BillingAddress != null)
            {
                order.BillingAddress = OrderAddress.CreateFrom(cart.BillingAddress);
            }

            order.ShippingCost = pricingContext.ShippingCost;
            order.PaymentMethodCost = pricingContext.PaymentMethodCost;
            order.Tax = pricingContext.Tax;
            order.Discount = pricingContext.TotalDiscount;

            order.Subtotal = pricingContext.Subtotal;
            order.Total = pricingContext.Total;

            Create(order);

            return order;
        }
示例#11
0
 public bool Create(Order order)
 {
     _orderRepository.Insert(order);
     Event.Raise(new OrderCreated(order), _instance);
     return true;
 }
示例#12
0
 public abstract bool CanExecute(Order order, CommerceInstance instance);
示例#13
0
 public OrderStatusChanged(Order order, OrderStatus? oldStatus, OrderStatus newStatus)
 {
     OrderId = order.Id;
     OldStatus = oldStatus;
     NewStatus = newStatus;
 }
示例#14
0
 public void UpdateTo(Order order)
 {
 }