public ActionResult Create(ProductoModels producto, HttpPostedFileBase file) { if (file != null && file.ContentLength > 0) { try { string imagepath = Server.MapPath("~/Images"); if (!Directory.Exists(imagepath)) { Directory.CreateDirectory(imagepath); } string Nombre = Convert.ToString(System.Guid.NewGuid()) + Path.GetFileName(file.FileName); string path = Path.Combine(imagepath, Nombre); file.SaveAs(path); producto.RutaImagen = Nombre; } catch (Exception ex) { ViewBag.Message = "ERROR:" + ex.Message.ToString(); } } else { producto.RutaImagen = string.Empty; } ProductoServicio.CrearProducto(producto.ToProductDomain()); return RedirectToAction("Details", "Catalogo", new { id = producto.CatalogoId }); }
// GET: Producto/Details/5 public ActionResult Details(int id) { ProductoModels Producto = new ProductoModels(ProductoServicio.FindById(id)); return View(Producto); }