Example #1
0
        [TestCase(1, "The Snorlax", 2016, "Stinky Pete", "The Garage", MPAA.R, true)]          //Correct date. Pass.

        public void CanEditDVDTest(int dvdId, string title, int year, string director, string studio, MPAA rating, bool expectedResult)
        {
            bool           result;
            LibraryManager manager = LibraryManagerFactory.Create();
            DVD            editDVD = manager.Get(dvdId);

            editDVD.Title        = title;
            editDVD.ReleaseYear  = year;
            editDVD.DirectorName = director;
            editDVD.Studio       = studio;
            editDVD.MPAARating   = rating;


            manager.Manage(editDVD);

            if (manager.GetAll().ToList().Count == 4)
            {
                result = true;
            }
            else
            {
                result = false;
            }

            Assert.AreEqual(expectedResult, result);
            Assert.AreEqual(editDVD.DvdId, dvdId);
            Assert.AreEqual(editDVD.Title, title);
            Assert.AreEqual(editDVD.ReleaseYear, year);
            Assert.AreEqual(editDVD.DirectorName, director);
            Assert.AreEqual(editDVD.Studio, studio);
            Assert.AreEqual(editDVD.MPAARating, rating);
        }
Example #2
0
        public ActionResult DisplayReport(Report ReportCriteria, int SearchMovie, DateTime?StartDate, DateTime?EndDate, DateTime?StartTime, DateTime?EndTime, MPAA MPAARating)
        {
            var query = from ut in db.UserTickets
                        select ut;

            query = query.Where(ut => ut.Status == Status.Active);

            if (SearchMovie != 0)
            {
                query = query.Where(ut => ut.MovieID == SearchMovie);
            }

            if (StartDate != null)
            {
                query = query.Where(ut => ut.Showing.ShowDate >= StartDate);
            }

            if (EndDate != null)
            {
                query = query.Where(ut => ut.Showing.ShowDate <= EndDate);
            }

            if (StartTime != null)
            {
                DateTime sTime = StartTime ?? new DateTime(1900, 1, 1);
                query = query.Where(ut => ut.Showing.ShowDate.TimeOfDay >= sTime.TimeOfDay);
            }

            if (EndTime != null)
            {
                DateTime eTime = StartTime ?? new DateTime(1900, 1, 1);
                query = query.Where(ut => ut.Showing.ShowDate.TimeOfDay <= eTime.TimeOfDay);
            }

            if (MPAARating != MPAA.All)
            {
                query = query.Where(ut => ut.Showing.Movie.MPAA_Rating == MPAARating);
            }

            if (ReportCriteria == Report.Seats)
            {
                List <UserTicket> ReportQuery = new List <UserTicket>();
                ReportQuery = query.ToList();
                ViewBag.SoldTicketsCount = ReportQuery.Count();
            }

            if (ReportCriteria == Report.Revenue)
            {
                Decimal decRevenue = 0;

                foreach (UserTicket ut in query)
                {
                    decRevenue = decRevenue + ut.CurrentPrice;
                }

                ViewBag.Revenue = decRevenue.ToString("C");
            }

            if (ReportCriteria == Report.Both)
            {
                List <UserTicket> ReportQuery = new List <UserTicket>();
                ReportQuery = query.ToList();
                ViewBag.SoldTicketsCount = ReportQuery.Count();

                Decimal decRevenue = 0;

                foreach (UserTicket ut in query)
                {
                    decRevenue = decRevenue + ut.CurrentPrice;
                }

                ViewBag.Revenue = decRevenue.ToString("C");
            }

            List <UserTicket> ReportTickets = new List <UserTicket>();

            ReportTickets = query.ToList();
            return(View("../Reports/DisplayReport", ReportTickets));
        }
Example #3
0
        [TestCase("FakeMovie", 1991, "Paul Rudd", "The Garage", MPAA.PG13, true)] //Correct information added. Pass.

        public void CanAddDVDTest(string title, int year, string director, string studio, MPAA rating, bool expectedResult)
        {
            bool           result;
            LibraryManager manager = LibraryManagerFactory.Create();
            DVD            mockDVD = new DVD();

            mockDVD.Title        = title;
            mockDVD.ReleaseYear  = year;
            mockDVD.DirectorName = director;
            mockDVD.Studio       = studio;
            mockDVD.MPAARating   = rating;


            manager.AddDVD(mockDVD);

            if (manager.GetAll().ToList().Count == 5)
            {
                result = true;
            }
            else
            {
                result = false;
            }

            Assert.AreEqual(expectedResult, result);
            Assert.AreEqual(mockDVD.DvdId, 5);
        }
        public ActionResult DisplayDetailedSearch(String SearchTitle, String SearchTagline, int[] SearchGenres, String SearchYear, String SearchActors, RangeType SearchYearType, MPAA MPAARating, String SearchStarRatings, StarComp SelectedStar)
        {
            var query = from m in db.Movies
                        select m;

            //List of movies w/ selected genres
            List <Movie> GenresMovies = new List <Movie>();
            List <Movie> FilterMovies = new List <Movie>();

            if (SearchTitle != null)
            {
                query = query.Where(m => m.Title.Contains(SearchTitle));
            }

            if (SearchTagline != null)
            {
                query = query.Where(m => m.Tagline.Contains(SearchTagline));
            }

            if (SearchGenres == null || SearchGenres.Count() == 0)
            {
            }
            else
            {
                //List<Genre> Genres = new List<Genre>();
                GenresMovies = query.ToList(); //List of movies from query
                //FilterMovies = query.ToList(); //We need two of these because you can't change the contents of the list during the loop. So we loop through GenresMovies and then remove the movies that don't fit the criteria from FilterMovies

                //foreach (int i in SearchGenres)
                foreach (Movie m in GenresMovies)
                {
                    foreach (int i in SearchGenres)
                    {
                        //If movie doesn't contain the genre, remove the movie from the list of movies
                        if (m.Genres.Contains(db.Genres.Find(i)) == true)
                        {
                            if (FilterMovies.Contains(m) == false)
                            {
                                FilterMovies.Add(m);
                            }
                        }
                    }
                }
            }

            if (SearchYear != null && SearchYear != "")
            {
                try
                {
                    Int32 DateSelected = Convert.ToInt32(SearchYear);
                    if (SearchYearType == RangeType.After)
                    {
                        query = query.Where(m => m.ReleaseYear >= DateSelected);
                    }
                    else if (SearchYearType == RangeType.Before)
                    {
                        query = query.Where(m => m.ReleaseYear <= DateSelected);
                    }
                    else if (SearchYearType == RangeType.Equal)
                    {
                        query = query.Where(m => m.ReleaseYear == DateSelected);
                    }
                }

                catch
                {
                    ViewBag.Message   = SearchYear + "is not a valid number.";
                    ViewBag.AllGenres = GetAllGenres();
                    ViewBag.AllMPAA   = GetAllMPAA();
                    return(View("DetailedSearch"));
                }
            }

            if (SearchActors != null)
            {
                query = query.Where(m => m.Actors.Contains(SearchActors));
            }

            if (MPAARating != MPAA.All)
            {
                query = query.Where(m => m.MPAA_Rating == MPAARating);
            }



            //Creates list of selected movies
            List <Movie> OtherMovies = query.ToList();
            List <Movie> FinalMovies = new List <Movie>();

            foreach (Movie item in OtherMovies)
            {
                FinalMovies.Add(item);
            }

            Decimal decSearchStar;

            if (SearchStarRatings != null && SearchStarRatings != "")
            {
                try
                {
                    decSearchStar = Convert.ToDecimal(SearchStarRatings);
                    if (decSearchStar >= 1.0m && decSearchStar <= 5.0m)
                    {
                        if (SelectedStar == StarComp.GreaterThan)
                        {
                            foreach (Movie item in OtherMovies)
                            {
                                if (item.RatingsAvg < decSearchStar)
                                {
                                    FinalMovies.Remove(item);
                                }
                            }
                        }
                        if (SelectedStar == StarComp.LessThan)
                        {
                            foreach (Movie item in OtherMovies)
                            {
                                if (item.RatingsAvg > decSearchStar)
                                {
                                    FinalMovies.Remove(item);
                                }
                            }
                        }
                    }
                    else
                    {
                        ViewBag.Message   = SearchStarRatings + "is not a valid number.";
                        ViewBag.AllGenres = GetAllGenres();
                        ViewBag.AllMPAA   = GetAllMPAA();
                        return(View("DetailedSearch"));
                    }
                }

                catch
                {
                    ViewBag.Message   = SearchStarRatings + "is not a valid number.";
                    ViewBag.AllGenres = GetAllGenres();
                    ViewBag.AllMPAA   = GetAllMPAA();
                    return(View("DetailedSearch"));
                }
            }


            var DisplayedMovies = FinalMovies;

            //If genres were selected, find the movies that have those genres and the other entered search requirements
            if (GenresMovies.Count() != 0)
            {
                Debug.WriteLine("Genres selected");
                DisplayedMovies = FinalMovies.Intersect(FilterMovies).ToList();
            }
            else //If not genres were selected, return the movies with the other filters
            {
                Debug.WriteLine("No genres selected");
                DisplayedMovies = FinalMovies;
            }

            List <Movie> SelectedMovies = DisplayedMovies.ToList();

            //Populates movie counts
            ViewBag.TotalMovies     = db.Movies.Count();
            ViewBag.DisplayedMovies = SelectedMovies.Count();

            SelectedMovies.OrderByDescending(m => m.Title);

            return(View("Index", SelectedMovies));
        }