public async Task <ActionResult <FilmClubDTO> > GetFilmClub(int filmClubId) { try { var filmClub = await _filmClubService.GetFilmClubById(filmClubId); return(Ok(filmClub.ToDto())); } catch { return(NotFound()); } }
public async Task <RentalModel> AddRentalOrderToDatabase(int filmClubId, int movieId) { try { if (!await IsRentalValid(filmClubId, movieId)) { throw new Exception("Rental is not valid"); } var filmClub = await _filmClubService.GetFilmClubById(filmClubId); var rentalOrder = await GenerateRentalOrderFrom(movieId); filmClub.Rentals.Add(rentalOrder); await _context.SaveChangesAsync(); return(rentalOrder); } catch (Exception e) { throw e; } }