Esempio n. 1
0
        public void UploadImageProduct(string ProductGuid, string Image)
        {
            shProductService _product = new shProductService();

            shProduct product = _product.FindByKey(ProductGuid);

            product.Image = Image;

            _product.Update(product);
        }
Esempio n. 2
0
        public void UnSubcribeHighLight(string[] cbxItem)
        {
            shProductService _product = new shProductService();
            shProduct        product  = new shProduct();

            foreach (var item in cbxItem)
            {
                product = _product.FindByKey(item);
                if (product != null)
                {
                    product.TopHot = false;
                    _product.Update(product);
                }
            }
        }
Esempio n. 3
0
        public shSaleDetail KiemTraSanPhamNamTrongChuongTrinhKhuyenMai(DateTime dt, string ProductGuid, string SizeGuid)
        {
            shSale       sale       = ChuongTrinhKhuyenMaiHienTai(dt);
            shSaleDetail saleDetail = new shSaleDetail();

            if (sale == null)
            {
                return(saleDetail);
            }

            shSaleDetailService        _saleService = new shSaleDetailService();
            IEnumerable <shSaleDetail> ds           = _saleService.DanhSachBySaleGuid(sale.SaleGuid);

            if (sale.DieuKienApDung == DieuKienApDungKhuyenMai.TatCaSanPham.GetHashCode())
            {
                saleDetail = ds.FirstOrDefault();
                return(saleDetail);
            }
            else if (sale.DieuKienApDung == DieuKienApDungKhuyenMai.TheoDanhMuc.GetHashCode())
            {
                shProductService _product = new shProductService();
                shProduct        product  = _product.FindByKey(ProductGuid);

                foreach (var item in ds)
                {
                    if (item.CategoryGuidProductGuid == product.CategoryGuid)
                    {
                        saleDetail = item;
                        return(item);
                    }
                }
            }
            else if (sale.DieuKienApDung == DieuKienApDungKhuyenMai.TheoSanPhamRiengBiet.GetHashCode())
            {
                shProductService _product = new shProductService();
                shProduct        product  = _product.FindByKey(ProductGuid);

                foreach (var item in ds)
                {
                    if (item.CategoryGuidProductGuid == product.ProductGuid)
                    {
                        saleDetail = item;
                        return(item);
                    }
                }
            }
            return(saleDetail);
        }
Esempio n. 4
0
        public string ProductName(string ProductGuid)
        {
            shProductService _product = new shProductService();

            if (!string.IsNullOrWhiteSpace(ProductGuid))
            {
                shProduct product = _product.FindByKey(ProductGuid);

                if (product != null)
                {
                    return(product.ProductName);
                }
                return(string.Empty);
            }

            return(string.Empty);
        }
Esempio n. 5
0
        public IEnumerable <shProduct> DanhSachProduct()
        {
            shProductService _product = new shProductService();

            return(_product.FindList().OrderBy(x => x.ProductId).Where(x => x.Status == true));
        }
Esempio n. 6
0
        public shProduct Inser_UpdateProduct(
            string ProductGuid,
            int ProductId,
            string CategoryGuid,
            string ProductName,
            decimal?PriceCurrent,
            string CompleteSetInclude,
            string Details,
            string UserManual,
            int?PercentCurrent,
            decimal?PriceAfterPercents,
            int?Number,
            string Image,
            int?ViewsProduct,
            int?ProductStatus,
            int?SortOrder,
            string Color,
            string Size,
            bool?Status,
            DateTime?CreateDate,
            string Description)
        {
            shProductService _product = new shProductService();
            shProduct        product  = new shProduct();

            try
            {
                // Your code...
                // Could also be before try if you know the exception occurs in SaveChanges

                if (!string.IsNullOrWhiteSpace(ProductGuid))
                {
                    product = _product.FindByKey(ProductGuid);
                }
                else
                {
                    product.ProductGuid = GuidUnique.getInstance().GenerateUnique();
                }

                //product.ProductId = ProductId;
                product.CategoryGuid       = CategoryGuid;
                product.ProductName        = ProductName;
                product.PriceCurrent       = PriceCurrent;
                product.CompleteSetInclude = CompleteSetInclude;
                product.Details            = Details;
                product.UserManual         = UserManual;
                product.PercentCurrent     = PercentCurrent;
                product.PriceAfterPercents = PriceAfterPercents;
                product.Number             = Number;

                product.ViewsProduct  = ViewsProduct;
                product.ProductStatus = ProductStatus;
                product.SortOrder     = SortOrder;
                product.Color         = Color;
                product.Size          = Size;
                product.Status        = Status;
                product.CreateDate    = CreateDate;
                product.Description   = Description;

                if (!string.IsNullOrWhiteSpace(Image) || !string.IsNullOrEmpty(Image))
                {
                    product.Image = Image;
                }

                product.MetaTitle = TaoLinkUrl(CategoryGuid, ProductName);

                if (product.ProductId > 0)
                {
                    _product.Update(product);
                }
                else
                {
                    _product.Insert(product);
                }
            }
            catch (DbEntityValidationException e)
            {
                foreach (var eve in e.EntityValidationErrors)
                {
                    Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                      eve.Entry.Entity.GetType().Name, eve.Entry.State);
                    foreach (var ve in eve.ValidationErrors)
                    {
                        Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                          ve.PropertyName, ve.ErrorMessage);
                    }
                }
                throw;
            }

            return(product);
        }