示例#1
0
        public VMProductSingle ProductSingleModel(int id)
        {
            VMProductSingle productModel = new VMProductSingle();
            var             x            = from product in dbContext.Products
                                           where product.ID == id
                                           select product;

            if (x.Count() == 1)
            {
                productModel.Product = x.First();
            }
            return(productModel);
        }
示例#2
0
        // GET: Product
        public ActionResult SingleProduct(int?id)
        {
            if (Session["Products"] == null)
            {
                Session["products"] = new List <SessionProduct>();
            }


            if (id.HasValue == false)
            {
                //Goto back to products page
                return(RedirectToAction("Products"));
            }
            else
            {
                VMProductSingle model = service.ProductSingleModel(id.Value);
                return(View("SingleProduct", model));
            }
        }