示例#1
0
        public void Post_WithCorrectValue_ReturnsCreated()
        {
            BudgetPlanViewModel viewModel = new BudgetPlanViewModel()
            {
                Year = 2017 - countBudgetPlans - 1
            };
            var response = budgetPlanController.Post(viewModel);

            Assert.IsType <CreatedResult>(response);
        }
示例#2
0
        public void Post_WithExistingYear_ReturnsBadRequest()
        {
            BudgetPlanViewModel viewModel = new BudgetPlanViewModel()
            {
                Status = status,
                Year   = 2016
            };
            var response = budgetPlanController.Post(viewModel);

            Assert.IsType <BadRequestObjectResult>(response);
        }
        public ActionResult Index()
        {
            ApplicationUser     user = db.Users.Find(User.Identity.GetUserId());
            BudgetPlanViewModel bpVM = new BudgetPlanViewModel();

            if (user.HouseholdId == null)
            {
                return(RedirectToAction("Index", "Manage"));
            }

            var budgetPlans          = db.BudgetPlans.Where(b => b.HouseholdId == user.HouseholdId).ToList();
            var budgetPlanCategories = db.BudgetPlanCategories.Where(b => b.HouseholdId == user.HouseholdId).ToList();

            bpVM.BudgetPlans          = budgetPlans;
            bpVM.BudgetPlanCategories = budgetPlanCategories;

            return(View(bpVM));
        }