public ActionResult Buy(int? Id) { if (Id == null || _productRepository.Products.All(p => p.Id != Id)) return PageNotFound("Item not found"); var details = new ProductShipmentDetailsViewModel { Product = _productRepository.Products.FirstOrDefault(p => p.Id == Id), ShippingCredentials = new ShippingDetails() }; return View(details); }
public ActionResult Buy(Product product, ProductShipmentDetailsViewModel details) { details.Product = _productRepository.Products .FirstOrDefault(p => p.Id == product.Id); if (!ModelState.IsValid) return View(details); string message = String.Empty; if (ModelState.IsValid) { message = _orderHandler.Handle(details.Product, details.ShippingCredentials); } return View("Success", (object)message); }