private void ApplyRowUpdate(DealRowViewModel row) { int indexOf = IndexOf(ActiveDeals, ad => ad.DealId == row.DealId); if (indexOf == -1) { ActiveDeals.Add(row); } else { ActiveDeals[indexOf] = row; } if (row.CategoryVersion >= _headVersion) { State = ViewModelState.Idle; } }
//private static DealRowViewModel AccumlateDealEvents(DealRowViewModel currentState, string eventPayload) private static DealRowViewModel AccumlateDealEvents(DealRowViewModel currentState, ResolvedEvent re) { var evt = Encoding.UTF8.GetString(re.Event.Data) .FromJson<CreateDealCommand>(); if (currentState == null) { return new DealRowViewModel(evt.DealId, re.OriginalEventNumber, re.Event.EventNumber) { Counterparty = evt.Counterparty, Trader = evt.Trader, Status = "Requested", Underlying = evt.Sections[0].ProductType, Notional = evt.Sections[0].Notional, Direction = Direction.Parse(evt.Sections[0].Direction), DeliveryStart = evt.Sections[0].DeliveryFrom, DeliveryEnd = evt.Sections[0].DeliveryUntil, PercentageFixed = 0 }; } //Not actually supported, yet. var row = new DealRowViewModel(evt.DealId, re.OriginalEventNumber, re.Event.EventNumber) { Counterparty = currentState.Counterparty, Trader = currentState.Trader, Status = currentState.Status, Underlying = currentState.Underlying, Notional = currentState.Notional, Direction = Direction.Parse(evt.Sections[0].Direction), DeliveryStart = currentState.DeliveryStart, DeliveryEnd = currentState.DeliveryEnd, PercentageFixed = currentState.PercentageFixed }; row.Counterparty = evt.Counterparty; row.Trader = evt.Trader; //row.Status = "Requested"; row.Underlying = evt.Sections[0].ProductType; row.Notional = evt.Sections[0].Notional; row.DeliveryStart = evt.Sections[0].DeliveryFrom; row.DeliveryEnd = evt.Sections[0].DeliveryUntil; row.PercentageFixed = 0; return row; }