Esempio n. 1
0
 public YearlyModel(Yearly yearly)
 {
     this.ID     = yearly.ID;
     this.year   = yearly.Year;
     this.Cost   = yearly.Cost;
     this.Remark = yearly.Remark;
 }
Esempio n. 2
0
 public YearlyModel(Yearly yearly)
 {
     this.ID = yearly.ID;
     this.year = yearly.Year;
     this.Cost = yearly.Cost;
     this.Remark = yearly.Remark;
 }
Esempio n. 3
0
 public ScheduleDefinition()
 {
     StartDate     = Controller.ScheduleController.GetToday();
     Type          = ScheduleType.Weekly;
     DaylyPeriod   = new Dayly();
     WeeklyPeriod  = new Weekly();
     MonthlyPeriod = new Monthly();
     YearlyPeriod  = new Yearly();
 }
Esempio n. 4
0
        public Yearly ToYearly()
        {
            Yearly yearly = new Yearly()
            {
                ID     = this.ID,
                Year   = this.Year,
                Cost   = this.Cost,
                Remark = this.Remark
            };

            return(yearly);
        }
Esempio n. 5
0
        public Yearly ToYearly()
        {
            Yearly yearly = new Yearly()
            {
                ID = this.ID,
                Year = this.Year,
                Cost = this.Cost,
                Remark = this.Remark
            };

            return yearly;
        }
Esempio n. 6
0
        /// <summary>
        /// Creates the range for years with the specified frequncy rate
        /// </summary>
        /// <param name="years">period count</param>
        /// <param name="frequncy">frequency rate</param>
        /// <returns>configured range object</returns>
        public static History Years(HowManyYears years, Yearly frequncy)
        {
            var ft = frequncy switch
            {
                Yearly.ByDay => Models.FrequencyType.Daily,
                Yearly.ByWeek => Models.FrequencyType.Weekly,
                Yearly.ByMonth => Models.FrequencyType.Monthly,
                _ => throw new NotImplementedException(),
            };

            return(Create(Models.PeriodType.Year, (ushort?)years, ft, null));
        }
Esempio n. 7
0
        public ActionResult Yearly()
        {
            var expenseList = DB.Expenses.ToList();

            var yearTotal = new Yearly();

            yearTotal.NumOfTransactions = expenseList.Count;

            foreach (var item in expenseList)
            {
                yearTotal.TotalSpent += item.Amount;
            }

            var avg = yearTotal.TotalSpent / yearTotal.NumOfTransactions;

            yearTotal.AverageSpent = Decimal.Round(avg, 2);

            ViewBag.TotalSpent      = yearTotal.TotalSpent;
            ViewBag.NumTransactions = yearTotal.NumOfTransactions;
            ViewBag.AverageSpent    = yearTotal.AverageSpent;

            var transType = expenseList.GroupBy(x => x.TransactionType)
                            .Select(group => new { Expens = group.Key, expenseList = group.ToList() })
                            .ToList();

            ViewBag.Titles = expenseList.Select(x => x.TransactionType).Distinct().ToList();

            var yearlyList = new List <Yearly>();

            foreach (var lines in transType)
            {
                var year = new Yearly();
                year.TransactionType   = lines.Expens;
                year.NumOfTransactions = lines.expenseList.Count;
                decimal total = 0;

                foreach (var item in lines.expenseList)
                {
                    total += item.Amount;
                }
                decimal average = total / year.NumOfTransactions;
                year.TotalSpent   = total;
                year.AverageSpent = Decimal.Round(average, 2);

                yearlyList.Add(year);
            }

            return(View(yearlyList));
        }