public ActionResult Details(int id) { var productApplication = new ProductApplication(SessionManager.GetInstance()); var product = productApplication.Get(id); return(View(product)); }
public JsonResult Adicionar(int id, int quantity) { var order = new Order(); order.Items = new List <Item>(); if (Session["MeuCarrinho"] != null) { order = (Order)Session["MeuCarrinho"]; } if (!order.Items.Any(x => x.ProductId == id)) { var productApplication = new ProductApplication(SessionManager.GetInstance()); var product = productApplication.Get(id); order.Items.Add(new Item { ProductId = product.Id, Price = product.Price, Quantity = quantity, Product = product }); Session["MeuCarrinho"] = order; return(Json(new { Resultado = "Sucesso" }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { Resultado = "JaExiste" }, JsonRequestBehavior.AllowGet)); } }
// GET: Product public ActionResult Index() { // Rever porque UI não enxerga repository // var products = _productApplication. // Será que esta esperando uma lista ? *** var products = _productApplication.Get().ToList(); return(View(products)); }
public ActionResult Edit(Guid id) { var vm = _productApplication.Get(id); if (vm != null) { ViewBag.Categories = new SelectList(_categoryApplication.List(), "Id", "Name"); return(View("Edit", vm)); } else { this.AddToastMessage("", "Product not found.", ToastType.Info); return(RedirectToAction("Index")); } }