Esempio n. 1
0
        public async Task <IActionResult> Detail(string urlSubgroup = null, string name = null, string color = null)
        {
            IEnumerable <ProductDetails> result;
            var pro = productBLL.SearchByUrl(name);

            if (pro == null)
            {
                return(NotFound());
            }
            var spe = pro.Specification;

            result = await productDetailsBLL.Get(filter : p => p.ProductID == pro.ID);

            string Color = null;

            if (color != null)
            {
                Color  = color;
                result = result.Where(p => p.TypeColor.ToString() == color);
            }
            else if (result.Count() > 0)
            {
                var firstProductDetails = result.FirstOrDefault();
                Color  = firstProductDetails.TypeColor.ToString();
                result = result.Where(p => p.TypeColor == firstProductDetails.TypeColor).ToList();
            }
            decimal price = pro.Price;
            //string IDtemp = id;
            List <string> listSize     = new List <string>();
            List <string> listColor    = new List <string>();
            List <string> listIdDetail = new List <string>();
            string        listImage    = null;

            if (result.Count() > 0)
            {
                foreach (var i in result)
                {
                    if (listColor.FirstOrDefault(p => p == i.TypeColor.ToString()) == null)
                    {
                        listColor.Add(i.TypeColor.ToString());
                    }
                }
                var selectedColor = result.FirstOrDefault().TypeColor;
                result = result.Where(p => p.TypeColor == selectedColor).ToList();

                foreach (var i in result)
                {
                    listImage = listImage + "," + i.listImages;
                    price     = i.Price;
                    listSize.Add(i.Size.ToString());
                    listIdDetail.Add(i.ID);
                }
            }
            LoadDetailsViewModel temp = new LoadDetailsViewModel()
            {
                ListIDDetails          = listIdDetail,
                ListSize               = listSize,
                ID                     = pro.ID,
                Color                  = Color,
                DefaultImages          = pro.DefaultImage,
                Model                  = pro.Model,
                ListImage              = listImage,
                ListColor              = listColor,
                Price                  = price == 0 ? "Chưa có hàng" : price.ToString(),
                Descrtiption           = pro.Details,
                Specification          = pro.Specification,
                IsAllowFacebookComment = pro.IsAllowComment,
                Quantity               = 0,
                CurrentSize            = "chua co",
                ImagePath              = pro.DefaultImage
            };

            ViewBag.Title = pro.MetaTitle;
            if (color != null)
            {
                ViewBag.Name = pro.Model + "-" + color;
            }
            else
            {
                ViewBag.Name = pro.Model;
            }

            ViewBag.Keyword     = pro.MetaDescription;
            ViewBag.Description = pro.MetaDescription;
            ViewBag.Image       = pro.DefaultImage;

            return(View("~/Views/Shop/Detail.cshtml", temp));
        }
Esempio n. 2
0
        public async Task <IActionResult> Detail(string id, string color = null)
        {
            IEnumerable <ProductDetails> result;

            if (color != null)
            {
                result = await ProductDetailsBLL.Get(filter : p => p.ProductID == id && p.TypeColor.ToString() == color);
            }
            else
            {
                result = await ProductDetailsBLL.Get(filter : p => p.ProductID == id);
            }
            var pro = await ProductBLL.Find(id);

            var spe = pro.Specification;

            if (pro == null)
            {
                return(NotFound());
            }
            decimal price = pro.Price;
            //string IDtemp = id;
            List <string> listSize     = new List <string>();
            List <string> listColor    = new List <string>();
            List <string> listIdDetail = new List <string>();
            string        listImage    = null;

            if (result.Count() > 0)
            {
                foreach (var i in result)
                {
                    if (listColor.FirstOrDefault(p => p == i.TypeColor.ToString()) == null)
                    {
                        listColor.Add(i.TypeColor.ToString());
                    }
                }
                var selectedColor = result.FirstOrDefault().TypeColor;
                result = result.Where(p => p.TypeColor == selectedColor).ToList();

                foreach (var i in result)
                {
                    listImage = listImage + "," + i.listImages;
                    price     = i.Price;
                    listSize.Add(i.Size.ToString());
                    listIdDetail.Add(i.ID);
                }
            }
            LoadDetailsViewModel temp = new LoadDetailsViewModel()
            {
                ListIDDetails          = listIdDetail,
                ListSize               = listSize,
                ID                     = pro.ID,
                Color                  = color,
                DefaultImages          = pro.DefaultImage,
                Model                  = pro.Model,
                ListImage              = listImage,
                ListColor              = listColor,
                Price                  = price == 0 ? "Chưa có hàng" : price.ToString(),
                Descrtiption           = pro.Details,
                Specification          = pro.Specification,
                IsAllowFacebookComment = pro.IsAllowComment,
                Quantity               = 0,
                CurrentSize            = "chua co",
                ImagePath              = pro.DefaultImage
            };

            return(View(temp));

            //return View();
        }
Esempio n. 3
0
        public async Task <IActionResult> Index()
        {
            var list = await ProductDetailsBLL.Get();

            return(View(list));
        }