public ActionResult AddFilm(Movie movi) { if (ModelState.IsValid == true) { if (Request.Files.Count > 0) { var file = Request.Files[0]; if (file != null && file.ContentLength > 0) { var fileName = Path.GetFileName(file.FileName); movi.Images = fileName; var path = Path.Combine(Server.MapPath("~/Content/image/"), fileName); file.SaveAs(path); } } Addedfilm.Saver(movi); return RedirectToAction("Films"); } else { return View(movi); } }
public static void Saver(Movie add) { using (var db = new DbMovieContext()) { db.Movies.Add(add); db.SaveChanges(); } }
public ActionResult Create(Movie movie) { if (!ModelState.IsValid) { return View(movie); } try { _service.AddMovie(movie); return RedirectToAction("Index"); } catch { return View(); } }
public virtual void AddMovie(Movie movie) { MovieList.Add(movie); }