コード例 #1
0
        private void CompileMonthlyProfitLossRatio(ref ProfitLossVM yearlyRatioRecord, ProfitsForProduct profitRecords, LossForProduct lossRecords, Month month)
        {
            int    Year           = yearlyRatioRecord.Year;
            double ProfitQuantity = profitRecords.ProfitsForProductInYear.FirstOrDefault(x => x.Year == Year).ProfitsPerMonth[month];
            double LossQuantity   = lossRecords.LossForProductInYear.FirstOrDefault(x => x.Year == Year).LossPerMonth[month];

            yearlyRatioRecord.Records.Add(new ProfitLossMonthlyVM()
            {
                Month  = Month.February,
                Profit = ProfitQuantity,
                Loss   = LossQuantity,
            });
        }
コード例 #2
0
        public List <ProfitLossVM> GetProfitLossRatio(Guid id)
        {
            List <ProfitLossVM> TotalRatioRecords = new List <ProfitLossVM>();
            ProfitsForProduct   ProfitRecords     = GetProfitForProduct(id);
            LossForProduct      LossRecords       = LossLogic.GetLossForProduct(id);

            int ProfitStartYear = ProfitRecords.StartYear;
            int ProfitsEndYear  = ProfitRecords.EndYear;
            int LossStartYear   = LossRecords.StartYear;
            int LossEndYear     = LossRecords.EndYear;

            int StartYear = ProfitStartYear < LossStartYear ? ProfitStartYear : LossStartYear;
            int EndYear   = ProfitsEndYear < LossEndYear ? LossEndYear : ProfitsEndYear;

            for (int i = StartYear; i <= EndYear; ++i)
            {
                ProfitLossVM YearlyRatioRecord = new ProfitLossVM {
                    Year = i
                };

                for (Month j = Month.January; j <= Month.December; ++j)
                {
                    switch (j)
                    {
                    case Month.January:
                        CompileMonthlyProfitLossRatio(ref YearlyRatioRecord, ProfitRecords, LossRecords, Month.January);
                        break;

                    case Month.February:
                        CompileMonthlyProfitLossRatio(ref YearlyRatioRecord, ProfitRecords, LossRecords, Month.February);

                        break;

                    case Month.March:
                        CompileMonthlyProfitLossRatio(ref YearlyRatioRecord, ProfitRecords, LossRecords, Month.March);
                        break;

                    case Month.April:
                        CompileMonthlyProfitLossRatio(ref YearlyRatioRecord, ProfitRecords, LossRecords, Month.April);
                        break;

                    case Month.May:
                        CompileMonthlyProfitLossRatio(ref YearlyRatioRecord, ProfitRecords, LossRecords, Month.May);
                        break;

                    case Month.June:
                        CompileMonthlyProfitLossRatio(ref YearlyRatioRecord, ProfitRecords, LossRecords, Month.June);
                        break;

                    case Month.July:
                        CompileMonthlyProfitLossRatio(ref YearlyRatioRecord, ProfitRecords, LossRecords, Month.July);
                        break;

                    case Month.August:
                        CompileMonthlyProfitLossRatio(ref YearlyRatioRecord, ProfitRecords, LossRecords, Month.August);
                        break;

                    case Month.September:
                        CompileMonthlyProfitLossRatio(ref YearlyRatioRecord, ProfitRecords, LossRecords, Month.September);
                        break;

                    case Month.October:
                        CompileMonthlyProfitLossRatio(ref YearlyRatioRecord, ProfitRecords, LossRecords, Month.October);
                        break;

                    case Month.November:
                        CompileMonthlyProfitLossRatio(ref YearlyRatioRecord, ProfitRecords, LossRecords, Month.November);
                        break;

                    case Month.December:
                        CompileMonthlyProfitLossRatio(ref YearlyRatioRecord, ProfitRecords, LossRecords, Month.December);
                        break;
                    }
                }
                TotalRatioRecords.Add(YearlyRatioRecord);
            }

            return(TotalRatioRecords);
        }