public async Task <GetProductCategoryForViewDto> GetProductCategoryForView(int id) { var productCategory = await _productCategoryRepository.GetAsync(id); var output = new GetProductCategoryForViewDto { ProductCategory = ObjectMapper.Map <ProductCategoryDto>(productCategory) }; return(output); }
public async Task <GetProductCategoryForViewDto> GetProductCategoryForView(int id) { var productCategory = await _productCategoryRepository.GetAsync(id); var output = new GetProductCategoryForViewDto { ProductCategory = ObjectMapper.Map <ProductCategoryDto>(productCategory) }; if (output.ProductCategory.ProductId != null) { var _lookupProduct = await _lookup_productRepository.FirstOrDefaultAsync((int)output.ProductCategory.ProductId); output.ProductName = _lookupProduct.Name.ToString(); } if (output.ProductCategory.CategoryId != null) { var _lookupCategory = await _lookup_categoryRepository.FirstOrDefaultAsync((int)output.ProductCategory.CategoryId); output.CategoryName = _lookupCategory.Name.ToString(); } return(output); }