Пример #1
0
        public IActionResult Edit(int productId, int categoryTypeId, int categoryId)
        {
            var product = _catalogItemRepository.GetById(productId);

            if (product == null)
            {
                return(NotFound());
            }

            ProductViewModel model = new ProductViewModel {
                Id             = product.Id,
                Name           = product.Name,
                Price          = product.Price.ToString(),
                PictureUri     = product.PictureUri,
                CategoryTypeId = categoryTypeId,
                CategoryId     = categoryId,
                Description    = product.Description,
                UnitsInStock   = product.UnitsInStock
            };

            ViewBag.Price = String.Format(product.Price % 1 == 0 ? "{0:0}" : "{0:0.00}", product.Price);
            return(View(model));
        }
Пример #2
0
 public async Task <CatalogItem> CatalogItem(Guid catalogId)
 {
     return(await _catalogItemRepository.GetById(catalogId));
 }