public ActionResult Edit(EnterPage page, HttpPostedFileBase file) { try { //EnterPage ep = db.EnterPage.First(); // Verify that the user selected a file if (file != null && file.ContentLength > 0) { // extract only the fielname var fileName = Path.GetFileName(file.FileName); // store the file inside ~/App_Data/uploads folder string newFileName = DateTime.Now.ToFileTimeUtc().ToString() + "_" + fileName; var path = Path.Combine(Server.MapPath("~/Content/uploads"), newFileName); file.SaveAs(path); page.Image = "/Content/uploads/" + newFileName; } db.Entry(page).State = EntityState.Modified; //ep.Text = page.Text; db.SaveChanges(); return RedirectToAction("Index", "Admin"); } catch { return View(db.EnterPage.First()); } }
public ActionResult Index() { WgArtists data = new WgArtists(); EnterPage model = new EnterPage(); model = (from a in data.EnterPage select a).FirstOrDefault(); return View(model); }
public ActionResult Create(EnterPage page, HttpPostedFileBase file) { if (ModelState.IsValid) { // Verify that the user selected a file if (file != null && file.ContentLength > 0) { // extract only the fielname var fileName = Path.GetFileName(file.FileName); // store the file inside ~/App_Data/uploads folder string newFileName = DateTime.Now.ToFileTimeUtc().ToString() + "_" + fileName; var path = Path.Combine(Server.MapPath("~/Content/uploads"), newFileName); file.SaveAs(path); page.Image = "/Content/uploads/" + newFileName; } db.EnterPage.Add(page); db.SaveChanges(); return RedirectToAction("Index", "Admin"); } return View(page); }
// // GET: /Enter/Create public ActionResult Create() { EnterPage ep = new EnterPage(); return View(ep); }