Esempio n. 1
0
        public ActionResult CreateNewUser(User user)
        {
            var ops = new DVDLibraryOperations();
            ops.CreateUser(user);

            return RedirectToAction("SelectUserRent");
        }
Esempio n. 2
0
        public ActionResult MovieToRepo(AddMovieCarrier newMovie)
        {
            var ops = new DVDLibraryOperations();
            ops.AddMovie(newMovie);

            return RedirectToAction("ViewCollection");
        }
Esempio n. 3
0
        public void AddMovieToDBTest()
        {
            var movie = new AddMovieCarrier();

            movie.Title = "Friday";
            movie.DateReleased = DateTime.Parse("11/02/1995");
            movie.MPAARatingID = "4";
            movie.GenreID = "5";
            movie.RunTime = "120";
            movie.StudioID = "1";
            movie.Synopsis =
                "Two homies, Smokey and Craig, smoke up a dope dealers weed and try to figure a way to get the $200 they owe the dope dealer by 10:00pm that night. In that time they smoke weed, get jacked, and they get shot at in a drive-by.";
            movie.OwnerRatingID = "5";
            movie.Copies = "2";
            movie.ImageURL = "http://www.imdb.com/media/rm3404111360/tt0113118?ref_=tt_ov_i";
            movie.DirectorID = new List<string>() {"1", "2"};
            movie.ActorID = new List<string>() {"1", "2", "3"};

            var ops = new DVDLibraryOperations();
            ops.AddMovie(movie);

            var movieAdded = new ViewMovieCarrier();

            using (SqlConnection cn = new SqlConnection(Settings.ConnectionString))
            {
                movieAdded = cn.Query<ViewMovieCarrier>("SELECT * FROM Movies m WHERE m.Title = 'Friday'").FirstOrDefault();
            }

            Assert.AreEqual(movieAdded.Title, movie.Title);
        }
Esempio n. 4
0
        public ActionResult SelectUserRent()
        {
            var ops = new DVDLibraryOperations();
            var users = ops.GetUsers().ToList();
            var usersVM = new SelectUserViewModel(users);

            return View(usersVM);
        }
Esempio n. 5
0
        public ActionResult RentDVD(int movieID)
        {
            var userID = (int) Session["User"];

            var ops = new DVDLibraryOperations();
            ops.RentDVD(movieID, userID);

            return RedirectToAction("ViewCollection", new {UserID = userID});
        }
Esempio n. 6
0
        public ActionResult ReturnMovie(int RentalId)
        {
            var ops = new DVDLibraryOperations();

            ops.ReturnMovieByRentalID(RentalId);
            Session["RentalID"] = RentalId;

            return RedirectToAction("RateMovie");
        }
Esempio n. 7
0
        public ActionResult RateMovie(RateMovieCarrier rateMovie)
        {
            var ops = new DVDLibraryOperations();
            ops.AddUserReview(rateMovie.Rating, rateMovie.MovieID, rateMovie.UserID, rateMovie.Note);

            var userRentalsVM = new RentalListViewModel(ops.GetUserOutForRent(rateMovie.UserID));

            return View("UserRentalList", userRentalsVM);
        }
Esempio n. 8
0
        public ActionResult RentalHistory()
        {
            var ops = new DVDLibraryOperations();

            var rentalHistory = ops.GetRentalHistory();

            var rentalVM = new RentalHistoryViewModel(rentalHistory);

            return View(rentalVM);
        }
Esempio n. 9
0
        public ActionResult DeleteDvD(int MovieID)
        {
            //possible undo implementation
            //Session["DeletedMovie"] = _deleted;
            _deleted.Push(MovieID);

            var ops = new DVDLibraryOperations();
            ops.DeleteMovie(MovieID);

            return RedirectToAction("ViewCollection");
        }
Esempio n. 10
0
        public HttpResponseMessage Post(ActorModel newActor)
        {
            var ops = new DVDLibraryOperations();
            ops.AddActor(newActor.FirstName, newActor.LastName);

            var response = Request.CreateResponse(HttpStatusCode.Created, newActor);

            string uri = Url.Link("DefaultApi", new { id = newActor.ActorID });
            response.Headers.Location = new Uri(uri);

            return response;
        }
Esempio n. 11
0
        public ActionResult RateMovie()
        {
            int RentalID = (int)Session["RentalID"];

            var ops = new DVDLibraryOperations();

            var rateMovie = ops.GetRateMovieDetailsByRentalID(RentalID);
            rateMovie.UserID = (int)Session["userID"];

            var rateMovieVM = new RateMovieViewModel(rateMovie);

            return View(rateMovieVM);
        }
Esempio n. 12
0
        public ActionResult AddMovie()
        {
            var ops = new DVDLibraryOperations();
            var mpaa = ops.GetMPAARatings();
            var genres = ops.GetGenres();
            var directors = ops.GetDirectors().OrderBy(m => m.FirstName).ToList();
            var studios = ops.GetStudios().OrderBy(m => m.Name).ToList();
            var actors = ops.GetActors().OrderBy(m=>m.FirstName).ToList();
            var ratings = ops.GetRatings();

            var addMovieVM = new AddMovieViewModel(mpaa, genres, directors, studios, actors, ratings);

            return View(addMovieVM);
        }
Esempio n. 13
0
        public void AddUserReviewTests(int Rating, int MovieID, int UserID, string NoteDescription, int noteCountAdder)
        {
            var ops = new DVDLibraryOperations();
            var ratingCountBefore = 0;
            var ratingCountAfter = 0;
            var noteCountBefore = 0;
            var noteCountAfter = 0;

            using (SqlConnection cn = new SqlConnection(Settings.ConnectionString))
            {
                ratingCountBefore = cn.Query<RatingModel>("SELECT * FROM MovieRatings").Count();
                noteCountBefore = cn.Query<Note>("SELECT * FROM Notes").Count();
                ops.AddUserReview(Rating, MovieID, UserID, NoteDescription);

                ratingCountAfter = cn.Query<RatingModel>("SELECT * FROM MovieRatings").Count();
                noteCountAfter = cn.Query<Note>("SELECT * FROM Notes").Count();
            }

            // Rating count should increase in both cases
            Assert.AreEqual(ratingCountBefore + 1, ratingCountAfter);

            // Note count should only increase with a valid note.
            Assert.AreEqual(noteCountBefore + noteCountAdder, noteCountAfter);
        }
Esempio n. 14
0
        public ActionResult ViewCollection(string MovieTitle)
        {
            var ops = new DVDLibraryOperations();
            var movies = ops.GetMovieListShortDetail();

            var filteredMovies = (from m in movies
                where m.Title.ToLower().Contains(MovieTitle.ToLower())
                select m).ToList();

            var collectionVM = new MovieCollectionViewModel(filteredMovies);

            return View(collectionVM);
        }
Esempio n. 15
0
        public List<ActorModel> Get()
        {
            var ops = new DVDLibraryOperations();

            return ops.GetActors();
        }
Esempio n. 16
0
        public ActionResult UserRentalList(int UserID)
        {
            Session["userID"] = UserID;
            var ops = new DVDLibraryOperations();

            var userRentalsVM = new RentalListViewModel(ops.GetUserOutForRent(UserID));

            return View(userRentalsVM);
        }
Esempio n. 17
0
        public ActionResult ViewCollection()
        {
            var ops = new DVDLibraryOperations();
            var movies = ops.GetMovieListShortDetail();

            var collectionVM = new MovieCollectionViewModel(movies);

            return View(collectionVM);
        }
Esempio n. 18
0
        public ActionResult ViewCollection(int UserID)
        {
            var ops = new DVDLibraryOperations();
            var moviesVM = new RentMovieShortViewModel(ops.GetMovieListRentShort());

            Session["User"] = UserID;

            return View(moviesVM);
        }
Esempio n. 19
0
        public ActionResult ViewMovieForRent(int movieID, int movieInventory)
        {
            var ops = new DVDLibraryOperations();
            var movie = ops.GetMovieDetails(movieID);
            var movieRatings = ops.GetMovieRatingsByID(movieID);

            var viewMovieVM = new RentMovieLongViewModel(movieRatings, movie);
            viewMovieVM.UserID = (int)Session["User"];
            viewMovieVM.MovieInventory = movieInventory;

            return View(viewMovieVM);
        }
Esempio n. 20
0
        public ActionResult ViewDVD(int MovieID)
        {
            var ops = new DVDLibraryOperations();
            var movie = ops.GetMovieDetails(MovieID);

            var dvdVM = new ViewMovieViewModel(movie);

            return View(dvdVM);
        }