Esempio n. 1
0
        public IActionResult AddMovie([FromBody] MovieModel model)
        {
            try
            {
                var movie = new Movies()
                {
                    BackgroundImage = model.BackgroundImage,
                    Director        = model.Director,
                    Image           = model.Image,
                    Pg            = model.Pg,
                    Published     = model.Published,
                    RunningTime   = model.RunningTime,
                    Synopsis      = model.Synopsis,
                    Title         = model.Title,
                    Title2        = model.Title2,
                    TrailerUrl    = model.TrailerUrl,
                    DateTimeAdded = DateTime.Now
                };

                _movies.AddMovie(movie, model.Genres);
                return(new JsonResult(new { StatusCodeResult = "200", message = "Movie has been successfully added" }));
            }
            catch (Exception ex)
            {
                return(new JsonResult(new { StatusCodeResult = "500", message = ex.Message }));
            }
        }
 public ActionResult AddData(Movie m, HttpPostedFileBase cover)
 {
     if (m.Title != null)
     {
         if (cover != null)
         {
             String[] temp      = cover.FileName.Split('.');
             String   path      = m.Title + "." + temp[1];
             String   pathForDb = Server.MapPath("~/Media/" + path);
             cover.SaveAs(pathForDb);
             m.Cover = "/Media/" + path;
         }
         movies.AddMovie(m);
         return(RedirectToAction("AdminPanel"));
     }
     return(RedirectToAction("Index", "Home"));
 }
Esempio n. 3
0
 public ViewResult Index(HomeViewModel model)
 {
     if (ModelState.IsValid)
     {
         MoviesDB addmovieDB = new MoviesDB()
         {
             Title         = model.Title,
             Genre         = model.Genre,
             RateMovie     = model.RateMovie,
             Price         = model.Price,
             ReleaseDate   = model.ReleaseDate,
             MainCharacter = model.MainCharacter,
             DirectedBy    = model.DirectedBy
         };
         _movies.AddMovie(addmovieDB);
         return(View(model));
     }
     return(View());
 }