예제 #1
0
        public async Task <ActionResult <FilmClubDTO> > GetFilmClub(int filmClubId)
        {
            try
            {
                var filmClub = await _filmClubService.GetFilmClubById(filmClubId);

                return(Ok(filmClub.ToDto()));
            }
            catch
            {
                return(NotFound());
            }
        }
예제 #2
0
        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;
            }
        }