public ActionResult Edit(EditOrderVM model)
        {
            var order = _orderService.GetOrder(model.Id);

            if (!ModelState.IsValid)
                return BuildModel(order, model);

            order.Status = model.Status;

            _notifier.Add(NotifyType.Information, T("The order has been saved"));
            return RedirectToAction("ListOrders", "CustomerAdmin", new { id = order.CustomerId });
        }
        private dynamic BuildModel(OrderPart order, EditOrderVM editModel)
        {
            CustomerPart customer = _customerService.GetCustomer(order.CustomerId);
            AddressPart shipAddressPart = _customerService.GetShippingAddress(customer.Id, order.Id);
            AddressPart custAddressPart = _customerService.GetInvoiceAddress(customer.Id);

            string shipName = string.Empty;
            if (shipAddressPart != null && !string.IsNullOrWhiteSpace(shipAddressPart.Name))
                shipName = shipAddressPart.Name;

            string shipAddress = shipAddressPart == null ? "(same as Invoice Address)" : shipAddressPart.Address;
            string shipAddress2 = shipAddressPart == null ? string.Empty : shipAddressPart.City + " " + shipAddressPart.State + " " + shipAddressPart.Postcode;
            string shipCountry = shipAddressPart == null ? string.Empty : shipAddressPart.Country;

            string custAddress = custAddressPart.Address;
            string custAddress2 = custAddressPart.City + " " + custAddressPart.State + " " + custAddressPart.Postcode;
            string custCountry = custAddressPart.Country;

            return Shape.Order(
                Order: order,
                CustomerName: customer.FullName,
                CustomerAddress1: custAddress,
                CustomerAddress2: custAddress2,
                CustomerCountry: custCountry,
                ShippingName: shipName,
                ShippingAddress1: shipAddress,
                ShippingAddress2: shipAddress2,
                ShippingCountry : shipCountry,
                Details: null, // Convert the whole thing to use Part instead of Record
                //Details: order.Details.Select( detail =>
                //    Shape.Detail
                //    (
                //        Sku: detail.Sku,
                //        Price: detail.UnitPrice,
                //        Quantity: detail.Quantity,
                //        Total: detail.Total,
                //        Description: detail.Description
                //    )).ToArray(),
                EditModel: editModel
            );
        }
        private dynamic BuildModel(OrderRecord order, EditOrderVM editModel)
        {
            CustomerPart customer = _customerService.GetCustomer(order.CustomerId);
            AddressPart shipAddressPart = _customerService.GetShippingAddress(customer.Id);
            AddressPart custAddressPart = _customerService.GetAddress(customer.Id, "InvoiceAddress");

            string shipName = string.Empty;
            if (!string.IsNullOrWhiteSpace(shipAddressPart.Name))
                shipName = shipAddressPart.Name;

            string shipAddress = shipAddressPart.Address;
            string shipAddress2 = shipAddressPart.City + " " + shipAddressPart.State + " " + shipAddressPart.Postcode;
            string shipCountry = shipAddressPart.Country;

            string custAddress = custAddressPart.Address;
            string custAddress2 = custAddressPart.City + " " + custAddressPart.State + " " + custAddressPart.Postcode;
            string custCountry = custAddressPart.Country;

            return Shape.Order(
                Order: order,
                CustomerName: customer.FullName,
                CustomerAddress1: custAddress,
                CustomerAddress2: custAddress2,
                CustomerCountry: custCountry,
                ShippingName: shipName,
                ShippingAddress1: shipAddress,
                ShippingAddress2: shipAddress2,
                ShippingCountry : shipCountry,
                Details: order.Details.Select( detail =>
                    Shape.Detail
                    (
                        Sku: detail.Sku,
                        Price: detail.UnitPrice,
                        Quantity: detail.Quantity,
                        Total: detail.Total,
                        Description: detail.Description
                    )).ToArray(),
                EditModel: editModel
            );
        }