public ActionResult RemoveProduct(RemoveProductViewModel model) { if (!ModelState.IsValid) return View(model); var command = new RemoveProductFromCart(model.CustomerId, model.ProductId); Bus.Send<RemoveProductFromCart>(command); return RedirectToAction("Index"); }
public void RemoveProductFromCart() { var customerController = _container.Resolve <CustomerController>(); var productController = _container.Resolve <ProductController>(); var cartController = _container.Resolve <CartController>(); var customersViewResult = customerController.Index() as ViewResult; var productsViewResult = productController.Index() as ViewResult; var model = new RemoveProductViewModel() { CustomerId = ((List <Customer>)customersViewResult.Model)[0].Id, ProductId = ((List <Product>)productsViewResult.Model)[0].Id }; var result = cartController.RemoveProduct(model) as RedirectToRouteResult; }
public ActionResult RemoveProduct(RemoveProductViewModel model) { if (!ModelState.IsValid) { return(View(model)); } using (ITransaction transaction = _session.BeginTransaction()) { var cart = _cartRepository.GetCartByCustomerId(model.CustomerId); var product = _productRepository.GetProduct(model.ProductId); cart.RemoveProduct(product); transaction.Commit(); } return(RedirectToAction("Index")); }
public async Task <ActionResult> Post(RemoveProductViewModel model) { await SendCommandAsync <RemoveProduct>(model); return(Accepted()); }