// GET: Transactions public ActionResult Index() { var data = db.GetAll(); var model = new List <Transactions>(); model = data.Select(e => new Transactions(e)).OrderBy(e => e.Date).ToList(); return(View(model)); }
// GET: Category public ActionResult Index() { var data = db.GetAll().OrderBy(e => e.Name); var model = new List <Category>(); foreach (var item in data) { model.Add(new Category(item)); model.Last().Total = new SqlDataServices <Data.Models.Transactions>().GetAll(item.ID, typeof(Category)).Sum(e => e.Amount); } model = model.OrderBy(e => e.Type).ThenBy(e => e.Name).ToList(); return(View(model)); }
// GET: Accounts public ActionResult Index() { var data = db.GetAll().OrderBy(e => e.Name); var model = new List <Accounts>(); foreach (var item in data) { //MIGHT NOT BE THE MOST EFFICENT WAY model.Add(new Accounts(item)); model.Last().Total = new SqlDataServices <Data.Models.Transactions>().GetAll(item.ID, typeof(Accounts)).Sum(e => e.Amount); } model = model.OrderByDescending(e => e.Active).ThenBy(e => e.Type).ThenBy(e => e.Name).ToList(); return(View(model)); }
// GET: Schedule public ActionResult Index() { AutomateSchedule.AddTransaction(); var data = db.GetAll(); var model = data.Select(e => new Schedule(e)).ToList(); return(View(model)); }
public IActionResult Index() { IEnumerable <Product> list = _services.GetAll(); GetDataViewModel vm = new GetDataViewModel { List = list, Time = DateTime.Now, Total = list.Count() }; return(View(vm)); }
public static void AddTransaction() { var todaysSchedule = db.GetAll("NextDueDay", DateTime.Today, "<=").Where(e => e.Frequency != Data.Enums.Frequency.PaidOff); foreach (var item in todaysSchedule) { var transaction = new Transactions { AccountsID = item.AccountsID, CategoryID = item.CategoryID, PayeeID = item.PayeeID, ScheduleID = item.ID, Amount = item.Amount, Date = item.NextDueDay, }; transactionsDb.Add(transaction); switch (item.Frequency) { case Data.Enums.Frequency.Monthly: item.NextDueDay = item.NextDueDay.AddMonths(1); break; case Data.Enums.Frequency.Weekly: item.NextDueDay = item.NextDueDay.AddDays(7); break; case Data.Enums.Frequency.Yearly: item.NextDueDay = item.NextDueDay.AddYears(1); break; case Data.Enums.Frequency.Quarterly: item.NextDueDay = item.NextDueDay.AddMonths(3); break; case Data.Enums.Frequency.OneTimePayment: item.Frequency = Data.Enums.Frequency.PaidOff; break; case Data.Enums.Frequency.EveryTwoWeeks: item.NextDueDay = item.NextDueDay.AddDays(14); break; case Data.Enums.Frequency.EveryFourWeeks: item.NextDueDay = item.NextDueDay.AddDays(28); break; case Data.Enums.Frequency.TwiceMonth: item.NextDueDay = item.NextDueDay.AddDays(14); break; case Data.Enums.Frequency.EveryTwoMonth: item.NextDueDay = item.NextDueDay.AddMonths(2); break; case Data.Enums.Frequency.TwiceYear: item.NextDueDay = item.NextDueDay.AddMonths(6); break; default: break; } if (item.TotalAmount.HasValue) { item.AmountCount = item.AmountCount.GetValueOrDefault() + (item.Amount < 0 ? item.Amount * -1 : item.Amount); } if (item.TotalCount.HasValue) { item.CountCount = item.CountCount.GetValueOrDefault() + 1; } if ((item.EndsOnDate.HasValue && item.NextDueDay > item.EndsOnDate) || (item.TotalAmount.HasValue && item.AmountCount >= item.TotalAmount) || (item.TotalCount.HasValue && item.CountCount >= item.TotalCount)) { item.Frequency = Data.Enums.Frequency.PaidOff; } db.Edit(item.ID, item); } }