Esempio n. 1
0
        public ProductDetailsModel ReadByProductId(ProductDetailsModel productDetailsModel)
        {
            string       productName  = null;
            ProductPrice productPrice = null;

            Parallel.Invoke(
                () => productName  = _redSkyRepository.GetProductName(productDetailsModel.Id),
                () => productPrice = _productRepository.GetProductCurrentPrice(productDetailsModel.Id)
                );
            return(string.IsNullOrWhiteSpace(productName)
                ? null
                : new ProductDetailsModel
            {
                Name = productName,
                CurrentPrice = productPrice,
                Id = productDetailsModel.Id
            });
        }
Esempio n. 2
0
        public ProductDetailsModel ReadByProductId(ProductDetailsModel productDetailsModel)
        {
            //Call out to HTTP GET for product name
            var productName = _redSkyRepository.GetProductName(productDetailsModel.Id);

            //Make sure productName exists and if so get the product price
            if (!string.IsNullOrEmpty(productName))

            {
                //nested conditional to check if productPrice is empty? or over doing it :|?
                //MongoCall
                var productPrice = _productPricesRepository.GetProductCurrentPrice(productDetailsModel.Id);
                productDetailsModel.Name         = productName;
                productDetailsModel.CurrentPrice = productPrice;
                return(productDetailsModel);
            }
            else
            {
                //Better error message? or is this check even needed? D:
                productDetailsModel.Name = "Product name is not found";
                return(productDetailsModel);
            }
        }