Ejemplo n.º 1
0
 public static void InsertFilm(FilmModel film)
 {
     using (var db = new SaitContext())
     {
         db.Films.Add(film);
         db.SaveChanges();
     }
 }
Ejemplo n.º 2
0
 public ActionResult AddFilm(FilmModel newfilm)
 {
     if (ModelState.IsValid)
     {
         if (Request.Files.Count > 0)
         {
             var file = Request.Files[0];
             if (file != null && file.ContentLength > 0)
             {
                 var fileName = Path.GetFileName(file.FileName);
                 string folder = Server.MapPath("~/Content/FilmsImages/");
                 var path = GetPathImageFilm.GetPathFromFileName(folder, fileName);
                 file.SaveAs(path);
                 newfilm.ImageFilms = fileName;
             }
             WorkFilms.InsertFilm(newfilm);
         }
         return RedirectToAction("GetFilmsList");
     }
     else
     {
         return View(newfilm);
     }
 }