void AbandonCommandMethod() { //abandon each visit purpose VisitPurposeVMs.ForEach(vp => vp.Abandon()); //set state of sender list item State = ExecuteTripSenderState.Abandoned; }
void CalcState() { //TODO: can get rid of those null checks? if (VisitPurposeVMs == null) { return; } //get number of abandoned visit purposes int abandonedCount = VisitPurposeVMs.Count(vp => vp.StateTemp == VisitPurposeState.Abandoned); //get number of unhandled visit purposes int unhandledCount = VisitPurposeVMs.Count(vp => vp.StateTemp == VisitPurposeState.Unhandled); //set state of sender to this destination according to counts State = (unhandledCount != 0 && abandonedCount == 0 ? ExecuteTripSenderState.Unhandled : (abandonedCount == VisitPurposeVMs.Count ? ExecuteTripSenderState.Abandoned : (abandonedCount == 0 ? ExecuteTripSenderState.Completed : ExecuteTripSenderState.PartsCompleted))); }