Example #1
0
 public ActionResult Delete(int id)
 {
     var command = new DeleteExpenseCommand { ExpenseId = id };
     var result = commandBus.Submit(command);
     DateTime startDate = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1);
     DateTime endDate = startDate.AddMonths(1).AddDays(-1);
     var expenses = expenseRepository.GetMany(exp => exp.Date >= startDate && exp.Date <= endDate);
     return PartialView("_ExpenseList", expenses);
 }
Example #2
0
        public void ExpenseDeleteTest()
        {
            using (var lifetime = container.BeginLifetimeScope())
            {
                IExpenseRepository expenseRepository = lifetime.Resolve<IExpenseRepository>();
                DefaultCommandBus commandBus = lifetime.Resolve<DefaultCommandBus>();

                Expense expense = expenseRepository.Get(c => c.Amount == 150);
                Assert.IsNotNull(expense, "Error: Expense was not found");

                DeleteExpenseCommand command = new DeleteExpenseCommand() { ExpenseId = expense.ExpenseId };
                ICommandHandler<DeleteExpenseCommand> commnadHandler = lifetime.Resolve<ICommandHandler<DeleteExpenseCommand>>();
                ICommandResult result = commandBus.Submit(command, commnadHandler);
                Assert.IsNotNull(result, "Error: Expense was not deleted");
                Assert.IsTrue(result.Success, "Error: Expense was not deleted");
            }
        }