Esempio n. 1
0
        public IActionResult Details(int id)
        {
            ViewData["BodyClass"] = "product-page";

            var detail = new DetailViewModel();

            detail.Product         = _productService.GetById(id);
            detail.Category        = _productCategoryService.GetById(detail.Product.CategoryId);
            detail.ProductImages   = _productService.GetImages(id);
            detail.RelatedProducts = _productService.GetRelatedProducts(id, 5);

            detail.UpsellProducts = _productService.GetUpSellProducts(5);
            detail.Colors         = _colorDapperService.GetColors(id).Select(n => new SelectListItem()
            {
                Value = n.Id.ToString(),
                Text  = n.Name
            }).ToList();

            detail.Sizes = _sizesDapperService.GetSizes(id).Select(n => new SelectListItem()
            {
                Value = n.Id.ToString(),
                Text  = n.Name
            }).ToList();

            detail.Tags = _productService.GetProductTags(id);

            return(View(detail));
        }
        public IActionResult GetColors(int productId)
        {
            var colors = _colorDapperService.GetColors(productId);

            return(new OkObjectResult(colors));
        }