Esempio n. 1
0
        public double GetProfitAmountForProduct(Guid productId, int year = 0, Month month = Month.None)
        {
            ProfitsForProduct       ProfitRecords       = GetProfitForProduct(productId);
            ProfitsForProductInYear ProfitRecordForYear = ProfitRecords.ProfitsForProductInYear.FirstOrDefault(x => x.Year == year);

            return(year == 0 ? ProfitRecords.ProfitsForProductInYear.Sum(x => x.ProfitsPerMonth.Sum(y => y.Value)) : (month == Month.None ? ProfitRecordForYear.ProfitsPerMonth.Sum(x => x.Value) : ProfitRecordForYear.ProfitsPerMonth[month]));
        }
        public Dictionary <string, double> AnnualProfitForProduct(Guid productId, int year)
        {
            Dictionary <string, double> Report       = new Dictionary <string, double>();
            ProfitsForProductInYear     ProfitRecord = ProfitLogic.GetProfitForProduct(productId).ProfitsForProductInYear
                                                       .FirstOrDefault(x => x.Year == year);

            if (ProfitRecord != null)
            {
                ProfitRecord.ProfitsPerMonth.Keys.ToList().ForEach(x => {
                    Report.Add(x.ToString(), ProfitRecord.ProfitsPerMonth[x]);
                });
            }
            return(Report);
        }