public ActionResult Create(Predefinida pizza, HttpPostedFileBase file) { string fileName = "", path = ""; // Verify that the user selected a file if (file != null && file.ContentLength > 0) { // extract only the fielname fileName = Path.GetFileName(file.FileName); // store the file inside ~/App_Data/uploads folder path = Path.Combine(Server.MapPath("~/Images/Uploads"), fileName); //string pathDef = path.Replace(@"\\", @"\"); file.SaveAs(path); } try { // TODO: Add insert logic here fileName = "/Images/Uploads/" + fileName; PredefinidaCEN pred = new PredefinidaCEN(); pred.New_(double.Parse(pizza.precio, System.Globalization.CultureInfo.InvariantCulture), pizza.Nombre, fileName, pizza.NumVeces, pizza.tamaño, pizza.masa, pizza.Descripcion); return(RedirectToAction("PanelAdmin", "Home")); } catch { return(View()); } }
public ActionResult Edit(int id) { Predefinida pred = null; SessionInitialize(); PredefinidaEN predEN = new PredefinidaCAD(session).ReadOIDDefault(id); pred = new AssemblerPredefinida().ConvertENToModelUI(predEN); SessionClose(); return(View(pred)); }
public ActionResult Edit(Predefinida pro, HttpPostedFileBase file) { string fileName = "", path = ""; // Verify that the user selected a file if (file != null && file.ContentLength > 0) { // extract only the fielname fileName = Path.GetFileName(file.FileName); // store the file inside ~/App_Data/uploads folder path = Path.Combine(Server.MapPath("~/Images/Uploads"), fileName); //string pathDef = path.Replace(@"\\", @"\"); file.SaveAs(path); } try { // TODO: Add update logic here ProductoCEN cen = new ProductoCEN(); if (fileName == "") { fileName = pro.Foto; } else { fileName = "/Images/Uploads/" + fileName; } cen.Modify(pro.Id, double.Parse(pro.precio, System.Globalization.CultureInfo.InvariantCulture), pro.Nombre, fileName, pro.NumVeces); return(RedirectToAction("IndexEdit")); } catch { return(View()); } }
public ActionResult Create() { Predefinida pred = new Predefinida(); return(View(pred)); }