Esempio n. 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);
        }
Esempio n. 2
0
        private int InitialiseDuebyDates(PlanningApp planningApp)
        {
            int noOfDatesUpdated = 0;
            var startState       = planningApp.PlanningAppStates.FirstOrDefault();

            startState.CurrentState = true;
            startState.DueByDate    = DateService.GetCurrentDate().AddBusinessDays(startState.state.CompletionTime);

            if (planningApp.PlanningAppStates.Count > 1)
            {
                noOfDatesUpdated = UpdateDueByDates(planningApp);
            }

            return(noOfDatesUpdated);
        }
Esempio n. 3
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);
        }
Esempio n. 4
0
        public PlanningApp RemoveGenerator(PlanningApp planningApp, int SequenceId, int GeneratorId)
        {
            var currentDate = DateService.GetCurrentDate();
            PlanningAppState newPlanningAppState = new PlanningAppState();

            //var generator = await StateInitialiserRepository.GetStateInitialiser(GeneratorId);
            var statesToDelete = planningApp.PlanningAppStates.Where(s => s.GeneratorOrder == SequenceId).ToList();

            foreach (var planningAppState in statesToDelete)
            {
                planningApp.PlanningAppStates.Remove(planningAppState);
            }
            //Shift states up
            planningApp.OrderedPlanningAppStates
            .Where(g => g.GeneratorOrder >= SequenceId)
            .Select(g => { g.GeneratorOrder--; return(g); })
            .ToList();

            UpdateDueByDates(planningApp);
            return(planningApp);
        }
Esempio n. 5
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);
        }