private PcsDailyResults GetTodaysFigures(List <BatchReport> currentDayReports)
        {
            PcsRework       rework = new PcsRework(_pcsReworkParameters, _helperMethods);
            PcsDailyResults output;

            if (currentDayReports.Count != 0)
            {
                output = new PcsDailyResults(currentDayReports.Select(x => x.StartTime).First(), _pcsScoringRepository);
                List <PcsParameterTotals> parameterTotals = new List <PcsParameterTotals>();

                parameterTotals.AddRange(GetWeightsForRecipeType(currentDayReports, RecipeTypes.Conc));
                parameterTotals.AddRange(GetWeightsForRecipeType(currentDayReports, RecipeTypes.Reg));
                parameterTotals.AddRange(GetWeightsForRecipeType(currentDayReports, RecipeTypes.BigBang));
                parameterTotals.Add(GetAllPerfumeWeights(currentDayReports));

                var dyes = GetAllDyeWeights(currentDayReports);
                if (dyes != null)
                {
                    parameterTotals.Add(dyes);
                }

                var activeTemps = GetAllActiveDropTemps(currentDayReports);
                if (activeTemps != null)
                {
                    parameterTotals.Add(activeTemps);
                }

                output.MaterialsChecked.AddRange(parameterTotals);
                output.DailyRework.AddRange(rework.CheckForReworkCompliance(currentDayReports));
                output.ProcessCompliance();
                return(output);
            }
            return(null);
        }
        public List <PcsDailyResults> GetResultsForEachDay(List <BatchReport> reportsThisWeek)
        {
            List <PcsDailyResults> output     = new List <PcsDailyResults>();
            DateTime currentDay               = GetFirstDateOfCurrentWeek(reportsThisWeek);
            int      amountOfDayToLookThrough = GetDaysToLoopThrough(currentDay);

            for (int i = 0; i < amountOfDayToLookThrough; i++)
            {
                List <BatchReport> currentDayReports = reportsThisWeek.Where(x => x.StartTime.Date == currentDay.Date).ToList();
                PcsDailyResults    todaysFigures     = GetTodaysFigures(currentDayReports);
                if (todaysFigures != null)
                {
                    output.Add(todaysFigures);
                }
                currentDay = currentDay.AddDays(1);
            }
            return(output);
        }
        public IViewComponentResult Invoke(PcsDailyResults pcsWeightsDailyResults)
        {
            PcsSummary pcsSummary = new PcsSummary
            {
                Date       = pcsWeightsDailyResults.Date,
                Title      = pcsWeightsDailyResults.Date.DayOfWeek.ToString() + " " + pcsWeightsDailyResults.Date.ToShortDateString() + " - Compliance " + pcsWeightsDailyResults.PcsCompliancePercentage.ToString("0.##") + "%",
                Percentage = pcsWeightsDailyResults.PcsCompliancePercentage
            };

            GetClassColours(pcsSummary, pcsWeightsDailyResults.PcsCompliancePercentage);

            foreach (var parameter in pcsWeightsDailyResults.MaterialsChecked)
            {
                PcsSummaryParameter currentParam = new PcsSummaryParameter();

                switch (parameter.Score)
                {
                case 0:
                    currentParam.Reasons = parameter.GetComplianceErrorsOutOfRange();
                    if (currentParam.Reasons.Count == 0)
                    {
                        currentParam.Reasons = parameter.GetComplianceErrorsOutOfTolerance();
                    }
                    currentParam.Heading    = parameter.GetErrorHeading();
                    currentParam.Subheading = parameter.GetSubheading();
                    break;

                case 1:
                    currentParam.Reasons    = parameter.GetComplianceErrorsOutOfTolerance();
                    currentParam.Heading    = parameter.GetErrorHeading();
                    currentParam.Subheading = parameter.GetSubheading();
                    break;

                default:
                    currentParam.Reasons = new List <KeyValuePair <string, string> >();
                    break;
                }
                pcsSummary.ParameterSummary.Add(currentParam);
            }


            return(View(pcsSummary));
        }