public bool UpdateMovie(Movie obj)
        {
            bool flag = false;

            Console.WriteLine("What are the updated movie details???");

            string MovieName1 = Console.ReadLine();
            string Director1  = Console.ReadLine();
            string Producer1  = Console.ReadLine();
            string Cast1      = Console.ReadLine();
            double Duration1  = double.Parse(Console.ReadLine());
            string Story1     = Console.ReadLine();
            string Type1      = Console.ReadLine();


            try
            {
                if (MovieName1 == null || Director1 == null || Producer1 == null || Story1 == null || Type1 == null || Cast1 == null || Duration1 == null)
                {
                    Console.WriteLine("Movie details should not be empty!!! ");
                }

                else if (obj == null)
                {
                    throw new Exception();
                }

                else if (Type1 != "Running" || Type1 != "Upcoming")
                {
                    Exceptions.InvalidMovieTypeException n1 = new Exceptions.InvalidMovieTypeException();
                }

                else
                {
                    obj.MovieName = MovieName1;
                    obj.Director  = Director1;
                    obj.Producer  = Producer1;
                    obj.Cast      = Cast1;
                    obj.Duration  = Duration1;
                    obj.Type      = Type1;
                    obj.Story     = Story1;
                    MovieTicketing.Movies.Add(obj);
                    flag = true;
                }
            }

            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            return(flag);
        }
Exemple #2
0
        //Add new movie to the Movies list collection of MovieTicketing class
        public bool AddMovie(Movie obj)
        {
            if (obj.MovieName == null || obj.Director == null || obj.Producer == null || obj.Story == null || obj.Type == null || obj.Cast == null || obj.Duration == null)
            {
                Console.WriteLine("Movie details should not be empty!!! ");
            }

            try
            {
                if (obj.Type != "Running" || obj.Type != "Upcoming")
                {
                    Exceptions.InvalidMovieTypeException n1 = new Exceptions.InvalidMovieTypeException();
                }
            }

            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            return(true);
        }
        public bool AddMovie(Movie obj)
        {
            bool flag = false;

            try
            {
                if (obj.MovieName == "" || obj.Director == "" || obj.Producer == "" || obj.Story == "" || obj.Type == "" || obj.Cast == "" || obj.Duration == null)
                {
                    Console.WriteLine("Movie details should not be empty!!! ");
                }


                else if (obj == null)
                {
                    throw new Exception();
                }

                else if (obj.Type != "Running" || obj.Type != "Upcoming")
                {
                    Exceptions.InvalidMovieTypeException n1 = new Exceptions.InvalidMovieTypeException();
                }

                else
                {
                    Movie m1 = new Movie(obj.MovieName, obj.Director, obj.Producer, obj.Cast, obj.Duration, obj.Story, obj.Type);
                    MovieTicketing.Movies.Add(m1);
                    flag = true;
                }
            }

            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            return(flag);
        }