예제 #1
0
        public IActionResult OrderProducts(int id)
        {
            var order         = orderService.GetOrderById(id);
            var orderProducts = productOrderService.GetOrderProducts(order);

            var dto = new List <OrderProductDto>();

            foreach (var prod in orderProducts)
            {
                var product = productService.GetProductById(prod.IdProduct);
                dto.Add(new OrderProductDto
                {
                    Product      = product,
                    ProductImage = productImageService.GetProductImages(product).FirstOrDefault(),
                    OrderProduct = prod
                });
            }

            var model = new OrderProductsViewModel
            {
                OrderProducts = dto,
            };

            return(PartialView("_OrderProducts", model));
        }
예제 #2
0
        public ActionResult <IEnumerable <ProductImage> > GetProductImages(int ProductId)
        {
            ProductImage productImage = new ProductImage();

            productImage.ProductId = ProductId;
            return(productImageService.GetProductImages(productImage).ToList());
        }
예제 #3
0
        public IEnumerable <Product> GetAllProducts()
        {
            var products = (from p in productRepo.TableNoTracking
                            orderby p.Name
                            select p)
                           .ToList();

            foreach (var prod in products)
            {
                foreach (var img in productImageService.GetProductImages(prod))
                {
                    prod.ProductImages.Add(img);
                }
            }

            return(products);
        }
예제 #4
0
        public IActionResult EditProduct(int id)
        {
            var allCategories   = categoryService.GetAllCategories();
            var product         = productService.GetProductById(id);
            var productCategory = categoryService.GetCategoryById(product.CategoryId);
            var units           = htmlHelper.GetEnumSelectList <EnumProductUnit>();
            var productImages   = productImageService.GetProductImages(product);

            var model = new ProductViewModel
            {
                Categories      = allCategories,
                Product         = product,
                ProductCategory = productCategory,
                Units           = units,
                ProductImages   = productImages
            };

            return(PartialView(model));
        }