예제 #1
0
        public bool addImageToMovie(image_movie temp)
        {
            try
            {
                db.image_movie.Add(temp);
                db.SaveChanges();

                return true;
            }
            catch
            {
                db.image_movie.Remove(temp);

                return false;
            }
        }
예제 #2
0
        public ActionResult UploadImage(AddImageToMovieModel imagePack)
        {
            if (imagePack != null)
            {
                image_movie temp = new image_movie();
                Guid newId = Guid.NewGuid();

                temp.id = newId;
                temp.movie_id = imagePack.movieId;
                temp.source = imagePack.source;
                temp.is_poster = imagePack.isPoster;

                if (dbMovie.addImageToMovie(temp).Equals(true))
                {
                    string path = System.IO.Path.Combine(Server.MapPath("~/Content/images/uploaded"),
                        temp.id.ToString() + ".png");
                    imagePack.file.SaveAs(path);
                }
            }
            return RedirectToAction("AddImage", "Movie");
        }