public async Task <PlanningApp> AppendGenerator(PlanningApp planningApp, int SequenceId, int NewGeneratorId) { var currentDate = DateService.GetCurrentDate(); PlanningAppState newPlanningAppState = new PlanningAppState(); var generator = await StateInitialiserRepository.GetStateInitialiser(NewGeneratorId); var generatorExists = planningApp.OrderedPlanningAppStates.Any(ps => ps.GeneratorOrder == SequenceId); //increase SequenceId of all future generators ad insert new one if (generatorExists) { planningApp.PlanningAppStates .Where(g => g.GeneratorOrder >= SequenceId) .Select(g => { g.GeneratorOrder++; return(g); }) .ToList(); } foreach (var state in generator.OrderedStates) { InsertPlanningState(planningApp, SequenceId, generator, state); } UpdateDueByDates(planningApp); return(planningApp); }
//Single Generator Creator private async Task <PlanningApp> AddSingleGeneratorStates(PlanningApp planningApp) { await InsertGenerator(planningApp, 1, planningApp.ProjectGeneratorId); //set first state to current state if (planningApp.PlanningAppStates.Count > 0) { var startState = planningApp.PlanningAppStates.FirstOrDefault(); var currentDate = DateService.GetCurrentDate(); startState.CurrentState = true; InitialiseDuebyDates(planningApp); } //Set overall Status to InProgress planningApp.CurrentPlanningStatus = statusList.Where(s => s.Name == StatusList.AppInProgress).SingleOrDefault(); return(planningApp); }
//NOT USED !!! Multi Generator creator (next version when dine front end) private async Task <PlanningApp> AddProjectGeneratorStates(PlanningApp planningApp) { // foreach(var gen in planningApp.ProjectGenerator.OrderedGenerators) { // //Console.WriteLine("Adding Generator " + gen.Generator.Name + " To Planning App"); //await InsertGenerator(planningApp, gen.SeqId, gen.Generator.Id) ; await InsertGenerator(planningApp, -1, -1); // } //set first state to current state if (planningApp.PlanningAppStates.Count > 0) { var startState = planningApp.PlanningAppStates.FirstOrDefault(); var currentDate = DateService.GetCurrentDate(); startState.CurrentState = true; InitialiseDuebyDates(planningApp); } //Set overall Status to InProgress planningApp.CurrentPlanningStatus = statusList.Where(s => s.Name == StatusList.AppInProgress).SingleOrDefault(); return(planningApp); }
public void Terminate(PlanningApp planningApp) { planningApp.CurrentPlanningStatus = statusList.Where(s => s.Name == StatusList.AppTerminated).SingleOrDefault(); //planningApp.Current().StateStatus = planningApp.CurrentPlanningStatus; PlanningAppRepository.UpdatePlanningApp(planningApp); }