private void PopulateOrders(int id, StringBuilder sb = null) { if (OrderDataList != null) { OrderDataList.ToList().ForEach(o => { o.DataUpdated -= OrderData_DataUpdated; }); OrderDataList.Clear(); } var list = model.GetOrdersByState((int)SelectedState.State, sb == null ? string.Empty : sb.ToString()); if (id == 0) { OrderDataList = list; } else { OrderDataList = new ObservableCollection <OrderData>(list.Where(od => od.OrdInfo.DistributorID == id).ToList()); } if (OrderDataList != null) { OrderDataList.ToList().ForEach(o => { o.SelectedStatus = model.StringStates[o.OrdInfo.OrderStatus]; o.DataUpdated += OrderData_DataUpdated; }); } }
private void performLocalSearch(bool shipBy) { if (shipBy == true) { PopulateOrders(0); OrderCount = OrderDataList.Count().ToString(); var shp = OrderDataList.Where(od => od.OrdInfo.PromissedDay.Equals(DtShipBy.ToShortDateString())).ToList(); if (OrderDataList != null) { OrderDataList.ToList().ForEach(o => { o.DataUpdated -= OrderData_DataUpdated; }); OrderDataList.Clear(); } if (shp != null && shp.Count > 0) { shp.ForEach(s => { s.DataUpdated += OrderData_DataUpdated; OrderDataList.Add(s); }); } OrderCount = OrderDataList.Count().ToString(); return; } var upc = OrderDataList.Where(od => od.OrdInfo.UPC.Equals(Search)).ToList(); if (upc != null && upc.Count() > 0) { OrderDataList.Clear(); upc.ForEach(u => { OrderDataList.Add(u); }); OrderCount = OrderDataList.Count().ToString(); return; } var sku = OrderDataList.Where(od => od.OrdInfo.SKU.Equals(Search)).ToList(); if (sku != null && sku.Count() > 0) { OrderDataList.Clear(); sku.ForEach(s => { OrderDataList.Add(s); }); OrderCount = OrderDataList.Count().ToString(); return; } var ordId = OrderDataList.Where(od => od.OrdInfo.OrderID.Equals(Search)).ToList(); if (ordId != null && ordId.Count() > 0) { OrderDataList.Clear(); ordId.ForEach(a => { OrderDataList.Add(a); }); OrderCount = OrderDataList.Count().ToString(); return; } var email = OrderDataList.Where(od => od.CustInfo.Email.Equals(Search)).ToList(); if (email != null && email.Count() > 0) { OrderDataList.Clear(); email.ForEach(e => { OrderDataList.Add(e); }); OrderCount = OrderDataList.Count().ToString(); return; } var name = OrderDataList.Where(od => od.CustInfo.Name.ToUpper().Contains(Search.ToUpper())).ToList(); if (name != null && name.Count() > 0) { OrderDataList.Clear(); name.ForEach(t => { OrderDataList.Add(t); }); OrderCount = OrderDataList.Count().ToString(); return; } var title = OrderDataList.Where(od => od.OrdInfo.Title.ToUpper().Contains(Search.ToUpper())).ToList(); if (title != null && title.Count() > 0) { OrderDataList.Clear(); title.ForEach(t => { OrderDataList.Add(t); }); OrderCount = OrderDataList.Count().ToString(); return; } var asin = OrderDataList.Where(od => od.OrdInfo.ASIN.Equals(Search)).ToList(); if (asin != null && asin.Count() > 0) { OrderDataList.Clear(); asin.ForEach(a => { OrderDataList.Add(a); }); OrderCount = OrderDataList.Count().ToString(); return; } var zipCD = OrderDataList.Where(od => od.CustInfo.ZipCode.ToUpper().Contains(Search.ToUpper())).ToList(); if (zipCD != null && zipCD.Count() > 0) { OrderDataList.Clear(); zipCD.ForEach(t => { OrderDataList.Add(t); }); OrderCount = OrderDataList.Count().ToString(); return; } }