public bool isLastGeneratorState(int planningAppStateId) { if (this.CurrentPlanningStatus.Name != StatusList.AppInProgress) { return(false); //Only interested in live applications when adding generators } var r = OrderedPlanningAppStates.GetEnumerator(); while (r.MoveNext()) { PlanningAppState prev = r.Current; if (r.Current.Id == planningAppStateId) { if (r.MoveNext()) { if (r.Current.GeneratorOrder > prev.GeneratorOrder && !prev.Completed()) //Cannot add generator if completed last gen state { return(true); } else { return(false); } } else { return(true); } } } return(false); }
//Private Functions public void SetCurrent(PlanningAppState planningAppState) { foreach (var state in OrderedPlanningAppStates) { state.CurrentState = false; } OrderedPlanningAppStates[OrderedPlanningAppStates.IndexOf(planningAppState)].CurrentState = true; }
public PlanningAppState SeekPrev(PlanningAppState planningAppState) //Get previous state based on specified State { if (!Completed() && !isFirstState(planningAppState)) { return(OrderedPlanningAppStates[OrderedPlanningAppStates.IndexOf(planningAppState) - 1]); } else { return(null); } }
public PlanningAppState SeekPrev() //Get previous state based on CurrentState { if (!Completed() && !isFirstState(Current())) { return(OrderedPlanningAppStates[OrderedPlanningAppStates.IndexOf(Current()) - 1]); } else { return(null); } }
public PlanningAppState SeekNext() { if (!Completed() && !isLastState(Current())) { return(OrderedPlanningAppStates[OrderedPlanningAppStates.IndexOf(Current()) + 1]); } else { return(null); } }
public PlanningAppState Next(PlanningAppState planningAppState) { PlanningAppState nextState = new PlanningAppState(); if (!isLastState(planningAppState)) { nextState = OrderedPlanningAppStates[OrderedPlanningAppStates.IndexOf(planningAppState) + 1]; planningAppState.CurrentState = false; nextState.CurrentState = true; return(nextState); } else { return(null); } }
private PlanningAppState FirstState(PlanningAppState planningAppState) { return(OrderedPlanningAppStates.Count() > 0 ? OrderedPlanningAppStates[0] : null); }
private PlanningAppState SeekLastState() { return(OrderedPlanningAppStates.Count() > 0 ? OrderedPlanningAppStates[OrderedPlanningAppStates.Count() - 1] : null); }
public PlanningAppState FirstState() { return(OrderedPlanningAppStates.FirstOrDefault()); }
public bool isFirstState(PlanningAppState planningAppState) { return(OrderedPlanningAppStates.IndexOf(planningAppState) == 0); }
public bool isLastState(PlanningAppState planningAppState) { return(OrderedPlanningAppStates.Count() == (OrderedPlanningAppStates.IndexOf(planningAppState) + 1)); }
public PlanningAppState Current() { return(OrderedPlanningAppStates.Where(s => s.CurrentState == true).SingleOrDefault()); }
public bool Completed() { return(OrderedPlanningAppStates.Where(p => p.CurrentState == true).Count() == 0); }