Esempio n. 1
0
        public bool saveMovie(Movie_Master newMovie)
        {
            db.MovieMaster.Add(newMovie.movie);
            db.SaveChanges();
            long newid = newMovie.movie.MovieId;

            foreach (var item in newMovie.actors)
            {
                db.CastingDetails.Add(new CastingDetails
                {
                    ActorId = item.ActorId,
                    MovieId = newid
                });
            }
            db.SaveChanges();
            return(true);;
        }
Esempio n. 2
0
        public List <Movie_Master> GetMovieList()
        {
            List <MovieMaster> movieList = db.MovieMaster.ToList();

            foreach (var movie in movieList)
            {
                var movie_info = new Movie_Master();
                movie_info.movie = movie;
                List <ActorMaster>    actorList   = new List <ActorMaster>();
                List <CastingDetails> movieActors = db.CastingDetails.Where(it => it.MovieId == movie.MovieId).ToList();
                movie_info.producer = db.ProducerMaster.Where(it => it.ProdId == movie.ProdId).FirstOrDefault();
                foreach (var actor in movieActors)
                {
                    var actorObj = db.ActorMaster.Where(it => it.ActorId == actor.ActorId).FirstOrDefault();
                    actorList.Add(actorObj);
                }
                movie_info.actors = actorList;
                movies.Add(movie_info);
            }
            return(movies);
        }
Esempio n. 3
0
        public bool updateMovie(Movie_Master newMovie)
        {
            var movieId = newMovie.movie.MovieId;
            var movie   = db.MovieMaster.Where(it => it.MovieId == movieId).FirstOrDefault();

            if (movie != null)
            {
                movie.MovieName   = newMovie.movie.MovieName;
                movie.Plot        = newMovie.movie.Plot;
                movie.ProdId      = newMovie.movie.ProdId;
                movie.ReleaseYear = newMovie.movie.ReleaseYear;
                movie.Thumbnail   = newMovie.movie.Thumbnail;
                db.SaveChanges();



                db.CastingDetails.RemoveRange(db.CastingDetails.Where(x => x.MovieId == movieId));

                foreach (var item in newMovie.actors)
                {
                    db.CastingDetails.Add(new CastingDetails
                    {
                        ActorId = item.ActorId,
                        MovieId = movieId
                    });
                }


                db.SaveChanges();



                return(true);
            }
            else
            {
                return(false);
            }
        }