示例#1
0
        public bool DeleteDirector(int directorId)
        {
            using (IMDBEntities7 dbContext = new IMDBEntities7())
            {
                var director = dbContext.Directors.Where(b => b.Id == directorId && b.Deleted == false).FirstOrDefault();
                if (director != null)
                {
                    director.Deleted = true;
                    dbContext.Entry(director).State = EntityState.Modified;
                    dbContext.SaveChanges();

                    DALMovie dALMovie = new DALMovie();
                    //kad brisemo rezisera, nece postojati vise ni filmovi koji su vezani za tog rezisera
                    var directedMovies = dbContext.Movies.Where(m => m.Director_Id == directorId && m.Deleted == false).ToList();
                    if (directedMovies != null)
                    {
                        directedMovies.ForEach(d =>
                        {
                            dALMovie.DeleteMovie(d.Id);
                        });
                    }
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
示例#2
0
        public List <Festival> GetFestivalsForMovie(int movieId)
        {
            List <Festival> festivals = new List <Festival>();
            DALMovie        dALMovie  = new DALMovie();
            var             movie     = dALMovie.GetMovieById(movieId);

            movie.Festivals.Where(a => !a.Deleted).ToList().ForEach(a => {
                festivals.Add(GetFestivalById(a.Id));
            });

            return(festivals);
        }
示例#3
0
        public bool DeleteDistributor(int distributorId)
        {
            try
            {
                using (IMDBEntities7 dbContext = new IMDBEntities7())
                {
                    var distributor = dbContext.Distributors.Where(b => b.Id == distributorId && b.Deleted == false).FirstOrDefault();
                    if (distributor != null)
                    {
                        distributor.Deleted = true;
                        dbContext.Entry(distributor).State = EntityState.Modified;
                        dbContext.SaveChanges();

                        DALMovie dALMovie          = new DALMovie();
                        var      distributedMovies = dbContext.Movies.Where(m => m.Distributor_Id == distributorId && m.Deleted == false).ToList();
                        //kad brisemo distributera, nece postojati vise ni filmovi vezani za njega
                        if (distributedMovies != null)
                        {
                            distributedMovies.ForEach(m =>
                            {
                                dALMovie.DeleteMovie(m.Id);
                            });
                        }

                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            catch (SqlException ex)
            {
                System.Diagnostics.Debug.WriteLine("Sql Exception:" + ex.Message);
                return(false);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Exception" + ex.Message);
                return(false);
            }
        }