public static void Patch(this CustomerOrder order, ShipNotice notice) { if (order.Shipments != null && order.Items.All(oi => notice.Items.Any(shi => shi.SKU == oi.ProductId && int.Parse(shi.Quantity) >= oi.Quantity))) { order.Shipments.ForEach(sh => { sh.Status = "Sent"; sh.Number = notice.TrackingNumber; //sh.DeliveryAddress = new Address //{ // AddressType = AddressType.Shipping, // City = shipnotice.Recipient.City, // CountryCode = shipnotice.Recipient.Country, // PostalCode = shipnotice.Recipient.PostalCode, // Line1 = shipnotice.Recipient.Address1, // Line2 = shipnotice.Recipient.Address2, // RegionName = shipnotice.Recipient.State != null && !shipnotice.Recipient.State.Length.Equals(2) ? shipnotice.Recipient.State : null, // RegionId = shipnotice.Recipient.State != null && shipnotice.Recipient.State.Length.Equals(2) ? shipnotice.Recipient.State : null, // Organization = shipnotice.Recipient.Company, // FirstName = shipnotice.Recipient.Name //}; }); order.Status = "Completed"; } }
public IHttpActionResult UpdateOrders(string action, string order_number, string carrier, string service, string tracking_number, ShipNotice shipnotice) { var order = _orderService.GetByOrderNumber(shipnotice.OrderNumber, CustomerOrderResponseGroup.Full); if (order == null) { return BadRequest("Order not found"); } order.Patch(shipnotice); _orderService.Update(new[] { order }); return Ok(shipnotice); }