Beispiel #1
0
        public async Task <IActionResult> BuyChildTicket(int movieId)
        {
            var result = await _unitOfWork.Repository <Movie>().GetAsync(movieId);

            if (result is null)
            {
                return(NotFound());
            }
            var specification = new MovieForKidsSpecification();

            if (!specification.IsSatisfiedBy(result))
            {
                return(Conflict("The mvie is not sutable for children"));
            }
            return(Ok(result));
        }
Beispiel #2
0
        private void BuyChildTicket(long movieId)
        {
            Maybe <Movie> movieOrNothing = _repository.GetOne(movieId);

            if (movieOrNothing.HasNoValue)
            {
                return;
            }

            Movie movie = movieOrNothing.Value;
            var   spec  = new MovieForKidsSpecification();

            if (!spec.IsSatisfiedBy(movie))
            {
                MessageBox.Show("The movie is not suitable for children", "Error",
                                MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            MessageBox.Show("You've bought a ticket", "Success",
                            MessageBoxButton.OK, MessageBoxImage.Information);
        }