Пример #1
0
        public ActionResult AddProduct(AddProductViewModel model)
        {
            if (!ModelState.IsValid)
                return View(model);

            var command = new AddProductToCart(model.CartId, model.ProductId, model.Quantity);
            Bus.Send<AddProductToCart>(command);

            return RedirectToAction("Index");
        }
Пример #2
0
        public Guid AddProductToCart()
        {
            var customerId = CreateCustomer();

            var controller = _container.GetInstance<CartController>();

            var viewResult = controller.Index(customerId) as ViewResult;
            var cartModel = viewResult.Model as CartView;

            var model = new AddProductViewModel()
            {
                CartId = cartModel.Id,
                ProductId = CreateProduct(),
                Quantity = 1
            };

            var result = controller.AddProduct(model) as RedirectToRouteResult;
            object view;
            result.RouteValues.TryGetValue("action", out view);
            Assert.AreEqual("Index", view);

            return customerId;
        }