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; }
public bool SaveOrder(Order order) { try { _orderService.Save(order); return true; } catch { return false; } }
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); } }
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); } }
public OrderCreated(Order order) : base(order, null, OrderStatus.Created) { OrderId = order.Id; }
public bool SaveOrder(Order order) { return Put<bool>(null, order); }
public override bool CanExecute(Order order, CommerceInstance instance) { return order.Status == OrderStatus.Paid && order.ProcessingStatus != "Approved"; }
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); }
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); }
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; }
public bool Create(Order order) { _orderRepository.Insert(order); Event.Raise(new OrderCreated(order), _instance); return true; }
public abstract bool CanExecute(Order order, CommerceInstance instance);
public OrderStatusChanged(Order order, OrderStatus? oldStatus, OrderStatus newStatus) { OrderId = order.Id; OldStatus = oldStatus; NewStatus = newStatus; }
public void UpdateTo(Order order) { }