public ActionResult Create(MonthlyExpense monthlyExpense)
        {
            if (monthlyExpensesRepository.HasExpenesRecoredForMonth(monthlyExpense.Month, monthlyExpense.Year, monthlyExpense.BranchName))
            {
                ModelState.AddModelError("Month", "Monthly Expenses already recorded for the given month.");
            }
            if (ModelState.IsValid)
            {
                monthlyExpensesRepository.Add(monthlyExpense);
                return RedirectToAction("Index");
            }

            ViewBag.Branches = MapBranchesToSelectListItems(branchRepository);

            return View(monthlyExpense);
        }
Пример #2
0
            public void Returns_MonthlyRevenue_with_MonthlyExpense_for_that_month()
            {
                var expectedMonthlyExpense = new MonthlyExpense();
                monthlyExpenseRepositoryMock.Setup(repo => repo.GetMonthlyExpenses(BranchName, currentTime.Month, currentTime.Year)).Returns(expectedMonthlyExpense);

                var monthlyRevenue = revenueService.ComputeMonthlyRevenue(BranchName, currentTime.Year, currentTime.Month);

                monthlyRevenue.MonthlyExpense.ShouldEqual(expectedMonthlyExpense);
            }
Пример #3
0
 public void SetUp()
 {
     monthlyExpense = new MonthlyExpense { BranchName = "foo", Year = 2012, Month = 1};
 }