Exemple #1
0
        public PartialViewResult EditSize(string SizeGuid, string SectionGuid, string ProductGuid)
        {
            shSizeService _size = new shSizeService();
            shSetSize     size  = _size.FindByKey(SizeGuid);

            if (size == null)
            {
                size = new shSetSize();
            }

            shSectionService           _section  = new shSectionService();
            IEnumerable <shProductSet> dsSection = _section.DanhSachSection_TheoProductGuid(ProductGuid);

            ViewBag.SectionGuid = new SelectList(dsSection, "SectionGuid", "SectionName", SectionGuid);

            IEnumerable <shSetSize> dsSize = _size.DanhSachSize_BySectionGuid(null, ProductGuid, null)
                                             .Where(x => string.IsNullOrWhiteSpace(x.ParentId) ||
                                                    string.IsNullOrEmpty(x.ParentId));

            foreach (var item in dsSize)
            {
                item.SizeName = _section.SectionName(item.SectionGuid) + " - " + item.SizeName;
            }
            ViewBag.Parent = new SelectList(dsSize, "SizeGuid", "SizeName", size.ParentId);
            //size.PriceCurrent = Format.SubStringDotInDecimal(size.PriceCurrent.Value);

            return(PartialView("EditSize", size));
        }
        public ActionResult SizeGuid(string ProductGuid, string SectionGuid, string SizeGuid)
        {
            if (string.IsNullOrWhiteSpace(SectionGuid) || string.IsNullOrEmpty(SectionGuid))
            {
                shSectionService _section = new shSectionService();

                IEnumerable <shProductSet> ds = _section.DanhSachSection_TheoProductGuid_ParentNull(ProductGuid);

                if (ds != null && ds.Count() > 0)
                {
                    SectionGuid = ds.FirstOrDefault().SectionGuid;
                }
            }

            shSizeService           _size  = new shSizeService();
            IEnumerable <shSetSize> dsSize = _size.DanhSachSize_BySectionGuid(SectionGuid, ProductGuid, null);

            foreach (var size in dsSize)
            {
                size.SizeName += " - " + Format.FormatDecimalToString(size.PriceCurrent.GetValueOrDefault(0)).Replace(',', '.');
            }
            SelectList select = new SelectList(dsSize, "SizeGuid", "SizeName", SizeGuid);

            return(PartialView("SizeGuid", select));
        }
        public ActionResult Details(int?id)
        {
            shProductService _product = new shProductService();

            shProduct product = _product.FindList().Where(x => x.ProductId == id).FirstOrDefault();

            shProductImageService        _productImage = new shProductImageService();
            IEnumerable <shProductImage> dsImage       = _productImage.DanhSachProductImage_ByProductGuid(product.ProductGuid);

            ViewBag.dsImageMauMa    = dsImage.Where(x => x.ProductImageCategory == Config.ProductImageCategory_Design);
            ViewBag.dsImageChatLieu = dsImage.Where(x => x.ProductImageCategory == Config.ProductImageCategory_Material);


            shSectionService           _section  = new shSectionService();
            IEnumerable <shProductSet> dsSection = _section.DanhSachSection_TheoProductGuid_ParentNull(product.ProductGuid);


            shProductSet section = new shProductSet();

            if (dsSection != null && dsSection.Count() > 0)
            {
                section = dsSection.FirstOrDefault();
            }

            shSizeService           _size  = new shSizeService();
            IEnumerable <shSetSize> dsSize = _size.DanhSachSize_BySectionGuid(section.SectionGuid, product.ProductGuid, null);


            ViewBag.ProductSize = section.SectionName + " --- " +
                                  CommonHelper.TinhToanKichThuocMaxMin(dsSize.FirstOrDefault(), dsSize.LastOrDefault());
            ViewBag.ProductPrice = CommonHelper.TinhToanGiaTienMaxMin(dsSize.FirstOrDefault(), dsSize.LastOrDefault());

            // Tính toán số tiền sau khuyến mại
            string productSale = CommonHelper.TinhToanGiaTienSauKhiGiam(dsSize.FirstOrDefault(), dsSize.LastOrDefault());

            if (!string.IsNullOrEmpty(productSale) && !string.IsNullOrWhiteSpace(productSale))
            {
                ViewBag.ProductSale = Format.FormatDecimalToString(Convert.ToDecimal(productSale));
            }


            ViewBag.ListSection = dsSection;

            return(View(product));
        }