Beispiel #1
0
        public ActionResult AddCategoryToBudgetPlan(BudgetPlanCategoryDto bpc)
        //public ActionResult AddCategoryToBudgetPlan(int BudgetPlanId, int CategoryId, bool UsePercent, decimal? AllocatedAmount, decimal? AllocatedPercentage)
        {
            string errMessage = null;

            if (bpc.AllocatedAmount == null && bpc.AllocatedPercentage == null)
            {
                ModelState.AddModelError("Amount unset", "Either a dollar amount or a percentage must set for each budget category.");
            }
            if (ModelState.IsValid)
            {
                BudgetPlanningService s = new BudgetPlanningService();
                s.AddCategoryToBudgetPlan(bpc);
            }
            else
            {
                errMessage = "";
                foreach (var val in ModelState.Values)
                {
                    foreach (var err in val.Errors)
                    {
                        errMessage += "\n" + err.ErrorMessage;
                    }
                }
            }
            return(BudgetPlanCategoryListing(bpc.BudgetPlanId, errMessage));
        }
Beispiel #2
0
        public ActionResult Delete(int budgetPlanCategoryId)
        {
            BudgetPlanningService s = new BudgetPlanningService();
            int budgetPlanId        = s.DeleteBudgetPlanCategory(budgetPlanCategoryId);

            return(BudgetPlanCategoryListing(budgetPlanId));
        }
Beispiel #3
0
        public ActionResult Create(string Name)
        {
            BudgetPlanningService s = new BudgetPlanningService();
            int newBudgetPlanId     = s.CreateNewBudgetPlan(Name);

            return(BudgetPlanCategoryListing(newBudgetPlanId));
        }
Beispiel #4
0
        public ActionResult BudgetPlanCategoryListing(int budgetPlanId, string ErrMessage = null)
        {
            BudgetPlanDto plan;

            try
            {
                BudgetPlanningService s = new BudgetPlanningService();
                plan = s.FillBudgetPlanDto(budgetPlanId);
                LookupService ls = new LookupService();
                plan.CategoryOptions = ls.GetCategoryList(budgetPlanId, false);
            }
            catch (Exception ex)
            {
                return(PartialView(ex.Message));
            }
            if (ErrMessage != null)
            {
                ViewBag.ErrMessage = ErrMessage;
            }
            return(PartialView("BudgetPlanCategoryListing", plan));
        }
Beispiel #5
0
        public ActionResult SavePercent(int budgetPlanCategoryId, string allocatedPercent)
        {
            BudgetPlanningService s     = new BudgetPlanningService();
            int            budgetPlanId = s.GetSelectedBudgetPlan();
            SummaryService ss           = new SummaryService();
            decimal        temp         = 0;

            allocatedPercent = allocatedPercent.Replace('%', (char)0);
            if (Decimal.TryParse(allocatedPercent, out temp))
            {
                BudgetPlanCategoryDto b = new BudgetPlanCategoryDto();
                b.BudgetPlanCategoryId = budgetPlanCategoryId;
                b.AllocatedPercentage  = allocatedPercent;
                b.UsePercent           = true;
                s.SaveBudgetPlanCategory(b);
            }
            else
            {
                ModelState.AddModelError(string.Empty, "Allocated percentage cannot be parsed as a decimal number. Please make sure Percent is a number.");
            }
            return(BudgetPlanCategoryListing(budgetPlanId));
        }
Beispiel #6
0
        public ActionResult SaveAmount(int budgetPlanCategoryId, string allocatedAmount)
        {
            BudgetPlanningService s = new BudgetPlanningService();
            int budgetPlanId        = s.GetSelectedBudgetPlan();

            allocatedAmount = allocatedAmount.TrimStart('$'); // get rid of the dollar signs
            decimal temp = 0;

            if (Decimal.TryParse(allocatedAmount, out temp))
            {
                BudgetPlanCategoryDto b = new BudgetPlanCategoryDto();
                b.BudgetPlanCategoryId = budgetPlanCategoryId;
                b.AllocatedAmount      = allocatedAmount;
                b.UsePercent           = false;
                s.SaveBudgetPlanCategory(b);
            }
            else
            {
                ModelState.AddModelError(string.Empty, "Allocated amount cannot be parsed as a decimal number. Please make sure Amount is a number.");
            }
            return(BudgetPlanCategoryListing(budgetPlanId));
        }
Beispiel #7
0
        // GET: BudgetPlaning
        public ActionResult Index()
        {
            BudgetPlanningService s = new BudgetPlanningService();

            return(View(s.GetSelectedBudgetPlan()));
        }