private OrderData ComputeOrderData() { var orderedEventLogs = EventLogs.Where(e => !e.TriggerStatus.IsFailure()).OrderByDescending(e => e.Context.Date).ToList(); var lastEditableEvent = orderedEventLogs.OfType <OrderParameterEventLog <IOrderEditableData> >().LastOrDefault(e => e.TriggerStatus.IsValid()); var lastDealEvent = orderedEventLogs.OfType <OrderParameterEventLog <IOrderDealingData> >().LastOrDefault(e => e.TriggerStatus.IsValid()); var lastValidEvent = orderedEventLogs.LastOrDefault(); var lastPendingEvent = orderedEventLogs.LastOrDefault(e => e.TriggerStatus.IsPending()); if (lastPendingEvent != null) { if (orderedEventLogs.Any(e => e.Trigger == lastPendingEvent.Trigger && e.Context.Date >= lastPendingEvent.Context.Date && e.TriggerStatus.IsPendingReply())) { ; } } var result = lastEditableEvent == null ? new OrderData() : new OrderData() .SetEditableData(lastEditableEvent.Parameters) .SetRoutingData(lastDealEvent == null ? null : lastDealEvent.Parameters) .SetOrderState(lastValidEvent.State) .SetTrigger(lastValidEvent.Trigger) .SetPendingTrigger(lastPendingEvent == null ? (OrderStateMachine.Trigger?)null: lastPendingEvent.Trigger); return(result.SetOrderStatus(ComputeOrderStatus(result))); }