Ejemplo n.º 1
0
        public int GetTotalLimit()
        {
            BudgetLimit lastLimit = Limits.Where(t => t.IsMonthly && t.StartDate < EndDate && (!t.EndDate.HasValue || t.EndDate > StartDate)).LastOrDefault();

            if (lastLimit == null)
            {
                return(0);
            }

            return(lastLimit.Limit * (MonthDifference(EndDate, StartDate) + 1));
        }
Ejemplo n.º 2
0
        public ActionResult Create(BudgetLimit budgetlimit)
        {
            if (ModelState.IsValid)
            {
                db.BudgetLimits.Add(budgetlimit);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(budgetlimit);
        }
Ejemplo n.º 3
0
        public List <BudgetLimit> GetSpecialLimitsInInterval(DateTime StartDate, DateTime EndDate)
        {
            List <BudgetLimit> limits        = db.BudgetLimits.Where(t => !t.IsMonthly && t.StartDate > StartDate && t.StartDate < EndDate).ToList();
            BudgetLimit        previousLimit = db.BudgetLimits.Where(t => !t.IsMonthly && t.StartDate < StartDate).OrderBy(t => t.StartDate).LastOrDefault();

            if (previousLimit != null)
            {
                limits.Add(previousLimit);
            }
            else
            {
                limits.Add(new BudgetLimit {
                    IsMonthly = false, Limit = 0, StartDate = DateTime.MinValue
                });
            }

            return(limits.OrderBy(t => t.StartDate).ToList());
        }
Ejemplo n.º 4
0
 public ActionResult Edit(BudgetLimit budgetlimit)
 {
     if (ModelState.IsValid)
     {
         db.Entry(budgetlimit).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(budgetlimit);
 }