Ejemplo n.º 1
0
        public ActionResult EditProduct(int id, FormCollection collection)
        {
            Product productForm = new Product()
            {
                IdProduct   = id,
                Title       = Request.Form["Item1.Title"],
                Synopsis    = Request.Form["Item1.Synopsis"],
                Price       = Convert.ToDecimal(Request.Form["Item1.Price"].Replace('.', ',')),
                ReleaseDate = Convert.ToDateTime(Request.Form["Item1.ReleaseDate"]),
                Picture     = Request.Form["Item1.Picture"],
                Stock       = Convert.ToInt32(Request.Form["Item1.Stock"]),
                TypeP       = new Videorama.Models.Type()
                {
                    IdType = Convert.ToInt32(Request.Form["Item1.TypeP"])
                }
            };

            ProductsDb dbProduct = new ProductsDb();
            bool       productValid;

            productValid = dbProduct.UpdateProduct(productForm);
            if (productValid)
            {
                return(RedirectToAction("Stock"));
            }
            else
            {
                return(RedirectToAction("EditProduct"));
            }
        }