Esempio n. 1
0
        public HttpResponseMessage UpdateShippingAddressLineItem(ShipmentDisplay shipment)
        {
            var merchShipment = _shipmentService.GetByKey(shipment.Key);

            // get the order keys from the shipment.  In general this will be a single
            // order but it is possible for this to be an enumeration
            var orderKeys = shipment.Items.Select(x => x.ContainerKey).Distinct();
            var orders    = _orderService.GetByKeys(orderKeys);

            // get the collection of invoices assoicated with the orders.
            // again, this is typically only one.
            var invoiceKeys = orders.Select(x => x.InvoiceKey).Distinct();
            var invoices    = _invoiceService.GetByKeys(invoiceKeys);

            foreach (var invoice in invoices)
            {
                // now we're going to update every shipment line item with the destination address
                var shippingLineItems = invoice.ShippingLineItems().ToArray();
                foreach (var lineItem in shippingLineItems)
                {
                    lineItem.ExtendedData.AddAddress(merchShipment.GetDestinationAddress(), Constants.ExtendedDataKeys.ShippingDestinationAddress);
                }
                _invoiceService.Save(invoice);
            }

            return(Request.CreateResponse(HttpStatusCode.OK));
        }
Esempio n. 2
0
        public ShipmentDisplay PutShipment(ShipmentDisplay shipment)
        {
            var merchShipment = _shipmentService.GetByKey(shipment.Key);
            var orderKeys     = shipment.Items.Select(x => x.ContainerKey).Distinct();

            if (merchShipment == null)
            {
                throw new NullReferenceException("Shipment not found for key");
            }

            merchShipment = shipment.ToShipment(merchShipment);

            _shipmentService.Save(merchShipment);

            this.UpdateOrderStatus(orderKeys);

            return(merchShipment.ToShipmentDisplay());
        }
Esempio n. 3
0
        public HttpResponseMessage PutShipment(ShipmentDisplay shipment)
        {
            var response = Request.CreateResponse(HttpStatusCode.OK);

            try
            {
                var merchShipment = _shipmentService.GetByKey(shipment.Key);

                if (merchShipment == null)
                {
                    return(Request.CreateResponse(HttpStatusCode.NotFound));
                }

                merchShipment = shipment.ToShipment(merchShipment);

                _shipmentService.Save(merchShipment);
            }
            catch (Exception ex)
            {
                response = Request.CreateResponse(HttpStatusCode.NotFound, String.Format("{0}", ex.Message));
            }

            return(response);
        }