public ActionResult EditImage(HttpPostedFileBase file) { Stanley stan; if (db.Stanley.FirstOrDefault() == null) { stan = new Stanley(); } else stan = db.Stanley.FirstOrDefault(); string[] split = file.ContentType.Split('/'); string filename = "Stanley." + split[1]; if (file == null || split[0] != "image") { return View(); } string fullPath = Request.MapPath("~/Images/" + filename); if (System.IO.File.Exists(fullPath)) { System.IO.File.Delete(fullPath); } if (db.Stanley.Count() == 0) db.Stanley.Add(stan); db.SaveChanges(); System.IO.File.Copy(file.FileName, Server.MapPath("~/Images/" + filename), true); stan.image = "../../Images/" + filename; db.SaveChanges(); return RedirectToAction("Index"); }
public ActionResult CreateBio(string bio) { Stanley stan = new Stanley(); stan.biographie = bio; db.Stanley.Add(stan); db.SaveChanges(); return RedirectToAction("Index"); }