Exemplo n.º 1
0
 public void TestDownload()
 {
     Order order = new Order();
     object results = Mozu.Mozu.Request(order);
     Assert.IsNotNull(results);
 }
Exemplo n.º 2
0
 private void downloadOrders()
 {
     Order orders = new Order();
     OrderCollection results = (OrderCollection) MZ.Request(orders, typeof(OrderCollection));
     if (results.Items != null) {
         foreach (Order o in results.Items) {
             //Warehouse.Warwick.Order order = new Warehouse.Warwick.Order();
             Warehouse.Order order = new Warehouse.Order();
             //order.order.system = _system;
             order.OrderNumber = o.OrderNumber.ToString();
             order.OrderDate = Utility.getDateTime(o.SubmittedDate);
             //order.BillTo = new Warehouse.Warwick.Customer {
             order.BillTo = new Warehouse.Customer {
                 FirstName = o.BillingInfo.BillingContact.FirstName,
                 LastName = o.BillingInfo.BillingContact.LastNameOrSurname,
                 Address1 = o.BillingInfo.BillingContact.Address.Address1,
                 Address2 = o.BillingInfo.BillingContact.Address.Address2,
                 City = o.BillingInfo.BillingContact.Address.CityOrTown,
                 State = o.BillingInfo.BillingContact.Address.StateOrProvince,
                 ZipCode = o.BillingInfo.BillingContact.Address.PostalOrZipCode,
                 Country = o.BillingInfo.BillingContact.Address.CountryCode,
                 Phone = o.BillingInfo.BillingContact.PhoneNumbers.Home,
                 Email = o.BillingInfo.BillingContact.Email,
             };
             /*order.ShipTo = new Warehouse.Warwick.Customer {
                 FirstName = o.Shipments[0].DestinationAddress.FirstName,
                 LastName = o.Shipments[0].DestinationAddress.LastNameOrSurname,
                 Address1 = o.Shipments[0].DestinationAddress.Address.Address1,
                 Address2 = o.Shipments[0].DestinationAddress.Address.Address2,
                 City = o.Shipments[0].DestinationAddress.Address.CityOrTown,
                 State = o.Shipments[0].DestinationAddress.Address.StateOrProvince,
                 ZipCode = o.Shipments[0].DestinationAddress.Address.PostalOrZipCode,
                 Country = o.Shipments[0].DestinationAddress.Address.CountryCode,
                 Phone = o.Shipments[0].DestinationAddress.PhoneNumbers.Home,
                 Email = o.Shipments[0].DestinationAddress.Email,
             };*/
             order.Save();
         }
     }
 }
Exemplo n.º 3
0
        public Warehouse.Order[] getOrders(int page=1, string orderNumber=null)
        {
            List<Warehouse.Order> orderList = new List<Warehouse.Order>();
            Order orders = new Order();
            //if (! string.IsNullOrWhiteSpace(orderNumber)) orders.OrderNumber = Utility.getInt(orderNumber);
            OrderCollection results = (OrderCollection) MZ.Request(orders, typeof(OrderCollection));
            if (results.Items != null) {
                foreach (Order o in results.Items) {
                    if (o.AuditInfo == null) continue;
                    if (Utility.getDateTime(o.AuditInfo.CreateDate) < new DateTime(2015, 5, 28)) continue;
                    if (! string.IsNullOrWhiteSpace(orderNumber) && o.OrderNumber.ToString() != orderNumber) continue;

                    Warehouse.Order order = new Warehouse.Order();
                    order.OrderNumber = o.OrderNumber.ToString();
                    order.OrderDate = Utility.getDateTime(o.SubmittedDate);

                    if (o.BillingInfo == null) continue;
                    order.BillTo = new Warehouse.Customer {
                        FirstName = o.BillingInfo.BillingContact.FirstName,
                        LastName = o.BillingInfo.BillingContact.LastNameOrSurname,
                        Address1 = o.BillingInfo.BillingContact.Address.Address1,
                        Address2 = o.BillingInfo.BillingContact.Address.Address2,
                        City = o.BillingInfo.BillingContact.Address.CityOrTown,
                        State = o.BillingInfo.BillingContact.Address.StateOrProvince,
                        ZipCode = o.BillingInfo.BillingContact.Address.PostalOrZipCode,
                        Country = o.BillingInfo.BillingContact.Address.CountryCode,
                        Phone = o.BillingInfo.BillingContact.PhoneNumbers.Home,
                        Email = o.BillingInfo.BillingContact.Email,
                    };
                    if (o.Shipments != null && o.Shipments.Count > 0) {
                        order.ShipTo = new Warehouse.Customer {
                            FirstName = o.Shipments[0].DestinationAddress.FirstName,
                            LastName = o.Shipments[0].DestinationAddress.LastNameOrSurname,
                            Address1 = o.Shipments[0].DestinationAddress.Address.Address1,
                            Address2 = o.Shipments[0].DestinationAddress.Address.Address2,
                            City = o.Shipments[0].DestinationAddress.Address.CityOrTown,
                            State = o.Shipments[0].DestinationAddress.Address.StateOrProvince,
                            ZipCode = o.Shipments[0].DestinationAddress.Address.PostalOrZipCode,
                            Country = o.Shipments[0].DestinationAddress.Address.CountryCode,
                            Phone = o.Shipments[0].DestinationAddress.PhoneNumbers.Home,
                            Email = o.Shipments[0].DestinationAddress.Email,
                        };
                    } else {
                        order.ShipTo = new Warehouse.Customer {
                            FirstName = o.FulfillmentInfo.FulfillmentContact.FirstName,
                            LastName = o.FulfillmentInfo.FulfillmentContact.LastNameOrSurname,
                            Address1 = o.FulfillmentInfo.FulfillmentContact.Address.Address1,
                            Address2 = o.FulfillmentInfo.FulfillmentContact.Address.Address2,
                            City = o.FulfillmentInfo.FulfillmentContact.Address.CityOrTown,
                            State = o.FulfillmentInfo.FulfillmentContact.Address.StateOrProvince,
                            ZipCode = o.FulfillmentInfo.FulfillmentContact.Address.PostalOrZipCode,
                            Country = o.FulfillmentInfo.FulfillmentContact.Address.CountryCode,
                            Phone = o.FulfillmentInfo.FulfillmentContact.PhoneNumbers.Home,
                            Email = o.FulfillmentInfo.FulfillmentContact.Email,
                        };
                    }

                    /** add the items */
                    List<Warehouse.Item> items = new List<Warehouse.Item>();
                    foreach (OrderItem item in o.Items) {
                        Warehouse.Item i = new Warehouse.Item();
                        i.SKU = item.Product.ProductCode;
                        i.Quantity = item.Quantity;
                        i.Price.Total = (double) item.Product.Price.Price;
                        if (i.Price.Total == 0) continue;
                        items.Add(i);
                    }
                    order.Items = items.ToArray();
                    if (order.Items.Length == 0) continue;

                    if (ordersAdded.Contains(order.OrderNumber)) continue;
                    ordersAdded.Add(order.OrderNumber);

                    orderList.Add(order);
                }
            }

            return orderList.ToArray();
        }
Exemplo n.º 4
0
 public void saveOrder(Warehouse.Order o)
 {
     Order order = new Order();
     order.OrderNumber = Utility.getInt(o.OrderNumber);
     order.SubmittedDate = o.OrderDate;
     order.Subtotal = (decimal) o.Price.SubTotal;
     order.TaxTotal = (decimal) o.Price.Tax;
     order.DiscountedTotal = (decimal) o.Price.Discount;
     order.ShippingTotal = (decimal) o.Price.ShippingCost;
     order.Total = (decimal) o.Price.Total;
     global::Mozu.Api.Contracts.CommerceRuntime.Fulfillment.Shipment shipment = new global::Mozu.Api.Contracts.CommerceRuntime.Fulfillment.Shipment();
     global::Mozu.Api.Contracts.Core.Contact contact = new global::Mozu.Api.Contracts.Core.Contact();
     global::Mozu.Api.Contracts.Core.Address address = new global::Mozu.Api.Contracts.Core.Address();
     address.Address1 = o.ShipTo.Address1;
     address.Address2 = o.ShipTo.Address2;
     address.Address3 = o.ShipTo.Address3;
     address.CityOrTown = o.ShipTo.City;
     address.StateOrProvince = o.ShipTo.State;
     address.PostalOrZipCode = o.ShipTo.ZipCode;
     address.CountryCode = o.ShipTo.Country;
     contact.PhoneNumbers = new global::Mozu.Api.Contracts.Core.Phone();
     contact.PhoneNumbers.Home = o.ShipTo.Phone;
     contact.PhoneNumbers.Mobile = o.ShipTo.Phone2;
     contact.Address = address;
     shipment.DestinationAddress = contact;
     order.Shipments.Add(shipment);
     MZ.Request(order, null, true);
 }