Example #1
0
        public HttpResponseMessage PutShipment(ShipmentOrderDisplay shipmentOrder)
        {
            var response = Request.CreateResponse(HttpStatusCode.OK);

            var shipment = shipmentOrder.ShipmentDisplay;
            var order    = shipmentOrder.OrderDisplay;

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

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

                merchShipment = shipment.ToShipment(merchShipment);
                if (order.Items.Count() == shipment.Items.Count())
                {
                    Notification.Trigger("OrderShipped", merchShipment, new[] { merchShipment.Email });
                }
                else
                {
                    Notification.Trigger("PartialOrderShipped", merchShipment, new[] { merchShipment.Email });
                }
                _shipmentService.Save(merchShipment);
            }
            catch (Exception ex)
            {
                response = Request.CreateResponse(HttpStatusCode.NotFound, String.Format("{0}", ex.Message));
            }

            return(response);
        }
        public HttpResponseMessage PutShipment(ShipmentOrderDisplay shipmentOrder)
        {
            var response = Request.CreateResponse(HttpStatusCode.OK);

            var shipment = shipmentOrder.ShipmentDisplay;
            var order    = shipmentOrder.OrderDisplay;

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

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

                merchShipment = shipment.ToShipment(merchShipment);


                // TODO this needs to be refactored in 1.5.1
                //if (order.Items.Count() == shipment.Items.Count())
                //{
                //    merchShipment.AuditCreated();
                //    Notification.Trigger("OrderShipped", merchShipment, new[] {merchShipment.Email});
                //}
                //else
                //{
                //    merchShipment.AuditCreated();
                //    Notification.Trigger("PartialOrderShipped", merchShipment, new[] { merchShipment.Email });
                //}

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

            return(response);
        }