Пример #1
0
        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);
        }
Пример #2
0
        //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);
        }
Пример #3
0
        //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);
        }
Пример #4
0
 public void Terminate(PlanningApp planningApp)
 {
     planningApp.CurrentPlanningStatus = statusList.Where(s => s.Name == StatusList.AppTerminated).SingleOrDefault();
     //planningApp.Current().StateStatus = planningApp.CurrentPlanningStatus;
     PlanningAppRepository.UpdatePlanningApp(planningApp);
 }