Exemplo n.º 1
0
        public async Task <IActionResult> GetMovieByIdAsync([FromRoute] MovieIdParameter movieIdParameter)
        {
            _ = movieIdParameter ?? throw new ArgumentNullException(nameof(movieIdParameter));

            string method = nameof(GetMovieByIdAsync) + movieIdParameter.MovieId;

            return(await ResultHandler.Handle(
                       dal.GetMovieAsync(movieIdParameter.MovieId), method, "Movie Not Found", logger)
                   .ConfigureAwait(false));
        }
Exemplo n.º 2
0
        public void MovieId_ValidateRegularExpression_ReturnsExpectedResult(string input, bool expectedResult)
        {
            // Arrange
            var movieIdParameter = new MovieIdParameter();

            // Act
            var isValid = IsValidProperty(movieIdParameter, input, "MovieId");

            // Assert
            Assert.Equal(expectedResult, isValid);
        }
Exemplo n.º 3
0
        public async Task <IActionResult> GetMovieByIdAsync([FromRoute] MovieIdParameter movieIdParameter)
        {
            if (movieIdParameter == null)
            {
                throw new ArgumentNullException(nameof(movieIdParameter));
            }

            string method = nameof(GetMovieByIdAsync) + movieIdParameter.MovieId;

            return(await DataService.Read <Movie>(Request).ConfigureAwait(false));

            //return await ResultHandler.Handle(
            //    dal.GetMovieAsync(movieIdParameter.MovieId), method, "Movie Not Found", logger)
            //    .ConfigureAwait(false);
        }
Exemplo n.º 4
0
        public async Task <IActionResult> GetMovieByIdAsync([FromRoute] MovieIdParameter movieIdParameter)
        {
            if (movieIdParameter == null)
            {
                throw new ArgumentNullException(nameof(movieIdParameter));
            }

            string method = nameof(GetMovieByIdAsync) + movieIdParameter.MovieId;

            IActionResult res = await ResultHandler.Handle(dal.GetMovieAsync(movieIdParameter.MovieId), method, "Movie Not Found", logger).ConfigureAwait(false);

            // use cache dal on Cosmos 429 errors
            if (res is JsonResult jres && jres.StatusCode == 429)
            {
                res = await ResultHandler.Handle(App.CacheDal.GetMovieAsync(movieIdParameter.MovieId), method, "Movie Not Found", logger).ConfigureAwait(false);
            }

            return(res);
        }