示例#1
0
        public IActionResult GetById(int itemId)
        {
            var item = _catalogItemRepository.GetByIdWithItemsAsync(itemId).Result;

            var viewModel = new ProductViewModel()
            {
                Id             = item.Id,
                Name           = item.Name,
                Price          = item.Price.ToString(),
                PictureUri     = item.PictureUri,
                CategoryTypeId = item.CatalogTypeId,
                CategoryId     = item.CatalogCategoryId,
                Description    = item.Description,
                Category       = new CategoryViewModel()
                {
                    Id = item.CatalogCategoryId, Type = _categoryRepository.GetById(item.CatalogCategoryId).Category
                },
                CategoryType = new CategoryViewModel()
                {
                    Id = item.CatalogTypeId, Type = _categoryRepository.GetTypeById(item.CatalogTypeId).Type
                }
            };

            return(View(viewModel));
        }