private void LoadOrderList() { this.orderList.Clear(); var ret = orderService.GetAllOrders().OrderByDescending(x => x.CreatedTime); foreach (var item in ret) { var recipient = this.recipientService.GetRecipient(item.RecipientId); var tempOrder = new OrderViewModel(item, recipient, this.orderService); tempOrder.PropertyChanged += new PropertyChangedEventHandler(orderVm_PropertyChanged); this.orderList.Add(tempOrder); } this.OrderCollectionView = CollectionViewSource.GetDefaultView(this.orderList); this.orderCollectionView.Filter = OrdersFilter; }
public void OnRecipientNewOrderAdded(RecipientNewOrderAddedEventPayload payload) { var recipient = this.recipientService.GetRecipient(payload.RecipientID); var orderItem = this.orderService.CreateOrder(recipient.ID); uint kg = 7; string detail = payload.DeclarationInfo; try { string detailRaw = payload.DeclarationInfo; var detailRawArray = detailRaw.ToLines(); var firstLine = detailRawArray.First().ToLower(); bool isFirstLineContainWeightInfo = firstLine.Contains("kg"); if (isFirstLineContainWeightInfo) { kg = (uint)firstLine.Replace("kg", "").StrToInt(); detail = string.Join(Environment.NewLine, detailRawArray.Skip(1)); } } catch { } orderItem.Content = payload.OrderInfo; orderItem.Detail = detail; orderItem.PacketWeight = kg; var orderVm = new OrderViewModel(orderItem, recipient,this.orderService); orderVm.PropertyChanged += new PropertyChangedEventHandler(orderVm_PropertyChanged); this.orderList.Add(orderVm); this.orderService.Add(orderVm.Order); this.orderCollectionView.Refresh(); }