Ejemplo n.º 1
0
        public ActionResult DialogHighLight(string ProductGuid, string ImageCarousel)
        {
            using (var context = new ShopOnlineDb())
            {
                using (var dbContextTransaction = context.Database.BeginTransaction())
                {
                    try
                    {
                        // 1. cập nhật ảnh đại diện sản phẩm
                        shProductService _product = new shProductService();
                        _product.UploadImageProduct(ProductGuid, ImageCarousel);

                        // 2. Upload file sản phẩm nổi bật
                        shProductImageService _productImage = new shProductImageService();
                        shProductImage        productImage  = new shProductImage();
                        productImage = _productImage.Insert_UpdateProductImage(
                            null,
                            null,
                            ProductGuid,
                            ImageCarousel,
                            null,
                            User.Identity.GetUserLogin().Userid,
                            true,
                            DateTime.Now,
                            Config.ProductImageCategory_Design,
                            Config.Product_Image_HighLight
                            );

                        dbContextTransaction.Commit();
                    }
                    catch (Exception ex)
                    {
                        dbContextTransaction.Rollback();
                    }
                }
            }

            if (Request.IsAjaxRequest())
            {
                return(Json("OK", JsonRequestBehavior.AllowGet));
            }
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 2
0
        public static string ProductHighLightImage(this HtmlHelper helper, string ProductGuid)
        {
            shProductImageService _productImage = new shProductImageService();

            IEnumerable <shProductImage> dsImage = _productImage.FindList()
                                                   .Where(x => x.ProductGuid == ProductGuid);

            string image = string.Empty;

            if (dsImage.Count() > 0)
            {
                shProductImage productDefault = dsImage.LastOrDefault();

                shProductImage productImage = dsImage.Where(x => x.Image == Config.Product_Image_HighLight).FirstOrDefault();

                if (!string.IsNullOrWhiteSpace(productImage.Image) || !string.IsNullOrEmpty(productImage.Image))
                {
                    return(productImage.FileName);
                }

                return(productDefault.FileName);
            }
            return(image);
        }