Ejemplo n.º 1
0
        public ActionResult AddProduct(Product newProduct, HttpPostedFileBase file)
        {
            productFac = new ProductFac(this.HttpContext);

            if (file.ContentLength > 0 && file != null)
            {
                string filePath = HttpContext.Request.PhysicalApplicationPath;
                file.SaveAs(filePath + "/Content/Images/Products/" + file.FileName);
                newProduct.Image = file.FileName;
            }
            else
            {
                newProduct.Image = "coming_soon.png";
            }

            TempData["MSG"] = "A product with name " + newProduct.Name + " has been created.";



            productFac.AddProduct(newProduct);
                
            return View("AddProduct");
        }
Ejemplo n.º 2
0
 public void AddProduct(Product productToAdd)
 {
     productToAdd.ProductID = products.Count + 1;
     products.Add(productToAdd);
     Context.Session["SessionProduct"] = products;
 }