public IActionResult Details(string id) { ProductDetailsServiceModel serviceModel = this.productService.GetById(id); ProductDetailsViewModel viewModel = this.mapper.Map <ProductDetailsViewModel>(serviceModel); return(this.View(viewModel)); }
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); }
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); }