Пример #1
0
        public ActionResult PSU_content(int? id)
        {
            ProductContent content = new ProductContent();
            using (var db0 = getDB0())
            {
                #region get content
                bool Exist = db0.Product.Any(x => x.product_id == id & !x.i_Hide & x.i_Lang == System.Globalization.CultureInfo.CurrentCulture.Name);
                if (id == null || !Exist)
                {
                    return Redirect("~/Products/PSU_list");
                }
                else
                {
                    content.item = db0.Product.Find(id);
                    content.item.l1_name = content.item.Product_Category_L1.l1_name;
                    content.item.l2_name = content.item.Product_Category_L2.l2_name;
                    content.item.l3_name = content.item.Product_Category_L3.l3_name;
                    content.item.models = content.item.ProductModel.OrderBy(x => x.sort).ToList();
                    content.item.imgsrc = GetImg(id.ToString(), "img1", "Active", "ProductData", null);
                    content.item.certificates = content.item.ProductCertificate.OrderBy(x => x.sort).ToList();

                    foreach (var i in content.item.certificates)
                    {
                        i.imgsrc = GetImg(i.product_certificate_id.ToString(), "Certificate", "Active", "ProductCertificate", null);
                    }
                    content.item.filesrc = GetFile(id.ToString(), "file1", "Active", "ProductData");
                    #region get other product
                    content.product_list = db0.Product.Where(x => !x.i_Hide &
                                                                  x.l1_id == content.item.l1_id &
                                                                  x.l2_id == content.item.l2_id &
                                                                  x.l3_id == content.item.l3_id &
                                                                  x.product_id != id &
                                                                  x.i_Lang == System.Globalization.CultureInfo.CurrentCulture.Name)
                                                     .OrderByDescending(x => x.sort)
                                                     .Select(x => new m_Product()
                                                     {
                                                         product_id = x.product_id,
                                                         power = x.power,
                                                         models = x.ProductModel.OrderBy(y => y.sort).ToList()
                                                     }).Take(20).ToList();
                    foreach (var i in content.product_list)
                    {
                        i.imgsrc = GetImg(i.product_id.ToString(), "img1", "Active", "ProductData", null);
                    }
                    #endregion
                }
                #endregion
            }
            ViewBag.l2_id = content.item.l2_id;
            ViewBag.l3_id = content.item.l3_id;
            return View(content);
        }
Пример #2
0
        // GET: Products
        public ActionResult Index(int? id)
        {
            ProductContent content = new ProductContent();
            using (var db0 = getDB0())
            {
                #region get content
                bool Exist = db0.Product.Any(x => x.product_id == id & !x.i_Hide & x.i_Lang == System.Globalization.CultureInfo.CurrentCulture.Name);

                if (id == null || !Exist)
                {
                    return Redirect("~/Products/list");
                }

                content.item = db0.Product.Find(id);
                content.item.l1_name = content.item.Product_Category_L1.l1_name;
                content.item.ImgScrs = GetImgs(id.ToString(), "Banner", "Active", "ProductData", null);
                #region get other product
                content.product_list = db0.Product.Where(x => !x.i_Hide &
                                                              x.category_id == content.item.category_id &
                                                              x.product_id != id &
                                                              x.i_Lang == System.Globalization.CultureInfo.CurrentCulture.Name)
                                                 .OrderByDescending(x => x.sort)
                                                 .Select(x => new m_Product()
                                                 {
                                                     product_id = x.product_id,
                                                     product_name = x.product_name,
                                                     models = x.ProductModel.OrderBy(y => y.sort).ToList()
                                                 }).Take(20).ToList();
                foreach (var i in content.product_list)
                {
                    i.imgsrc = GetImg(i.product_id.ToString(), "List", "Active", "ProductData", null);
                }
                #endregion

                #endregion
            }
            //ViewBag.product_id = content.item.product_id;
            return View("Products", content);
        }