Example #1
0
        public void DiscountPercentage_NullCheck()
        {
            // Arrange
            const decimal expectedDiscount = 0M;

            // Act
            var result = ps_.DiscountPercentage(null);

            // Assert
            Assert.Equal(expectedDiscount, result);
        }
Example #2
0
        public async Task <Movie> GetAsync(int id, string code = null)
        {
            var movie = await context_.Movie
                        .SingleOrDefaultAsync(m => m.MovieId == id);

            if (movie == null)
            {
                return(null);
            }

            var discount = pricing_.DiscountPercentage(code);

            movie.Price -= movie.Price * (discount / 100);

            return(movie);
        }
Example #3
0
        public IActionResult Get(int id, string code)
        {
            var product = default(ProductItem);

            if (string.IsNullOrWhiteSpace(code))
            {
                return(BadRequest(product));
            }

            product = _reposvc.Get(id);

            if (product == null)
            {
                return(NotFound(product));
            }

            product.DiscountPercentage = _pricsvc.DiscountPercentage(code);

            return(Ok(product));
        }