public IActionResult Details(string id)
        {
            ProductDetailsServiceModel serviceModel = this.productService.GetById(id);

            ProductDetailsViewModel viewModel = this.mapper.Map <ProductDetailsViewModel>(serviceModel);

            return(this.View(viewModel));
        }
コード例 #2
0
        public ProductDetailsServiceModel GetById(string id)
        {
            Product product = this.dbContext.Products.FirstOrDefault(x => x.Id == id);

            if (product == null)
            {
                throw new ArgumentNullException(ExceptionMessages.invalidId);
            }

            ProductDetailsServiceModel serviceModel = this.mapper.Map <ProductDetailsServiceModel>(product);

            return(serviceModel);
        }
コード例 #3
0
        public ProductDetailsServiceModel GetById(string id)
        {
            Product product = this.dbContext.Products.Find(id);

            if (product == null)
            {
                throw new ArgumentException(ExceptionMessages.ProductNotFound);
            }

            ProductDetailsServiceModel serviceModel = this.mapper.Map <ProductDetailsServiceModel>(product);

            return(serviceModel);
        }