示例#1
0
 public ActionResult Delete(int id)
 {
     var command = new DeleteCategoryCommand { CategoryId = id };
     var result = commandBus.Submit(command);
     var categories = categoryRepository.GetAll();
     return PartialView("_CategoryList", categories);
 }
示例#2
0
        public void CategoryDeleteTest()
        {
            using (var lifetime = container.BeginLifetimeScope())
            {
                ICategoryRepository categoryRepository = lifetime.Resolve<ICategoryRepository>();
                DefaultCommandBus commandBus = lifetime.Resolve<DefaultCommandBus>();

                Category category = categoryRepository.Get(c => c.Name == "Updated Test Category");
                Assert.IsNotNull(category, "Error: Category was now found.");

                DeleteCategoryCommand command = new DeleteCategoryCommand() { CategoryId = category.CategoryId };
                ICommandHandler<DeleteCategoryCommand> commnadHandler = lifetime.Resolve<ICommandHandler<DeleteCategoryCommand>>();
                ICommandResult result = commandBus.Submit(command, commnadHandler);
                Assert.IsNotNull(result, "Error: Category was not deleted by CommandBus");
                Assert.IsTrue(result.Success, "Error: Category was not deleted by CommandBus");
            }
        }