public void CreateAmazonOrder(SalesOrder order) { dynamic amazonOrder = new AmazonOrders(); var existingOrder = amazonOrder.First(OrderNumber: order.OrderId); dynamic map = new ExpandoObject(); map.Store = "Amazon"; map.StoreEntityId = order.NativeId; map.OrderNumber = order.OrderId; map.StoreCreatedAt = order.StoreCreatedAt; map.StoreUpdatedAt = order.StoreUpdatedAt; map.StoreStatus = order.StoreStatus; map.CustomerName = order.DeliveryCustomerName; map.ShipStreet = order.DeliveryStreet; map.ShipCity = order.DeliveryCity; map.ShipState = order.DeliveryState; map.ShipZip = order.DeliveryZip; map.ShipCountry = order.DeliveryCountry; if(existingOrder == null) { NLog.LogManager.GetCurrentClassLogger().Warn("Create amazon order: {0}", order.OrderId); map.CreatedAt = DateTime.Now; var newId = amazonOrder.Insert(map); } else if(existingOrder.StoreStatus != order.StoreStatus) { NLog.LogManager.GetCurrentClassLogger().Warn("Update amazon order: {0}", order.OrderId); map.Updatedat = DateTime.Now; amazonOrder.Update(map,existingOrder.Id); } }
public void GetSpecificOrderAndMapToAx() { var store = new AmazonStore(); var amazonId = "102-2130201-6848236"; dynamic table = new AmazonOrders(); var rec = table.First(OrderNumber:amazonId); var salesOrder= store.MapFromAmazonCache(rec); store.GetOrderItems(salesOrder); }
public List<SalesOrder> GetUnprocessedOrders() { var salesOrder = new List<SalesOrder>(); var table = new AmazonOrders(); var unprocessedOrders = table.Query(@"select ao.* from CandyDirectAmazonOrders ao left join CandyDirectProcessedOrders po on ao.ordernumber = po.ordernumber where po.id is null and ao.StoreStatus <> 'Canceled' and ao.StoreStatus <> 'Pending'"); unprocessedOrders.ToList().ForEach(x => salesOrder.Add(MapFromAmazonCache(x))); salesOrder.ForEach( x => GetOrderItems(x)); return salesOrder; }