コード例 #1
0
        public async Task <Rental> GetAsync(object id)
        {
            Entities.Rental dbRental = await _viFlixContext.Rentals.FindAsync(id);

            if (dbRental == null)
            {
                return(new Rental());
            }

            return(Converter.ToModelRental(dbRental));
        }
コード例 #2
0
        public async void Remove(Rental model)
        {
            Entities.Rental dbRental = await _viFlixContext.Rentals.FindAsync(model.Id);

            if (dbRental == null)
            {
                return;
            }

            _viFlixContext.Rentals.Remove(dbRental);
        }
コード例 #3
0
        public async void Add(Rental model)
        {
            Customer customer = await _viFlixContext.Customers.FindAsync(model.Customer.Id);

            Movie movie = await _viFlixContext.Movies.FindAsync(model.Movie.Id);

            var rentalToBeSaved = new Entities.Rental
            {
                Customer         = customer,
                Movie            = movie,
                DateRented       = model.DateRented,
                DateToBeReturned = model.DateToBeReturned
            };

            _viFlixContext.Rentals.Add(rentalToBeSaved);
        }