コード例 #1
0
        public async Task <ActionResult <ProductVM> > Product(int id)
        {
            ProductDTO productDto = await _catalogManager.Product(id);

            if (productDto == null || productDto.Id != id)
            {
                return(NotFound());
            }

            return(View(new ProductVM
            {
                Id = productDto.Id,
                Name = productDto.Name,
                Brand = productDto.Brand == null ? null : new BrandVM
                {
                    Id = productDto.Brand.Id,
                    Name = productDto.Brand.Name
                },
                Category = productDto.Category == null ? null : new CategoryVM
                {
                    Id = productDto.Category.Id,
                    Name = productDto.Category.Name
                },
                Character = productDto.Character,
                Country = productDto.Country == null ? null : new CountryVM
                {
                    Id = productDto.Country.Id,
                    Name = productDto.Country.Name
                },
                Description = productDto.Description,
                Image = productDto.Image,
                Price = productDto.Price,
                Weight = productDto.Weight,
                BrandId = productDto.BrandId,
                CategoryId = productDto.CategoryId,
                CountryId = productDto.CountryId
            }));
        }