示例#1
0
        public static void RentMovie(int trackNumber)

        {
            var movie = db.MoviesDetails.SingleOrDefault(m => m.TrackNumber == trackNumber);

            if (movie == null)
            {
                //throw exception
                return;
            }



            var movieRental = new MovieRental
            {
                MovieName    = movie.MovieName,
                Language     = movie.Language,
                ReleasedYear = movie.ReleasedYear,
                RentalType   = TypesOfRental.Rent,
                Amount       = movie.RentAmount,
                TrackNumber  = trackNumber
            };

            db.MoviesRental.Add(movieRental);
            db.SaveChanges();
        }
示例#2
0
        public static void BuyMovie(int trackNumber)

        {
            var movie = db.MoviesDetails.SingleOrDefault(m => m.TrackNumber == trackNumber);

            if (movie == null)
            {
                throw new ArgumentNullException();
            }


            var movieRental = new MovieRental
            {
                MovieName    = movie.MovieName,
                Language     = movie.Language,
                ReleasedYear = movie.ReleasedYear,
                RentalType   = TypesOfRental.Buy,
                Amount       = movie.BuyAmount,
                TrackNumber  = trackNumber
            };

            db.MoviesRental.Add(movieRental);
            db.SaveChanges();
        }