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)); }
public async void Remove(Rental model) { Entities.Rental dbRental = await _viFlixContext.Rentals.FindAsync(model.Id); if (dbRental == null) { return; } _viFlixContext.Rentals.Remove(dbRental); }
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); }