public ActionResult GetProductName(string query)
        {
            svFavProduct = new FavProductService();

            sqlWhere  = svFavProduct.CreateWhereAction(FavAction.IsFav, 0);
            sqlWhere += svFavProduct.CreateWhereCause(0, query, 0, 0, 0, 0, 0, 0, 0);

            var FavProducts = svFavProduct.SelectData <view_FavProduct>("ProductName", sqlWhere, "ProductName");
            var ProductName = FavProducts.Select(it => it.ProductName).ToList();

            return(Json(ProductName));
        }
Exemplo n.º 2
0
        //

        #region myfav list
        public ActionResult myfav(int compid, int pageindex = 1, int pagesize = 50)
        {
            var svFav        = new FavProductService();
            var svProduct    = new ProductService();
            var fav          = svFav.SelectData <view_FavProduct>(" * ", "isdelete = 0 AND compid = " + compid, "", pageindex, pagesize);
            var product      = new List <ProductModel>();
            var gallery      = new List <b2bProductImage>();
            var whereGallery = "IsDelete = 0";

            #region product gallery
            if (svFav.TotalRow > 0)
            {
                List <int> productid = fav.Select(m => (int)m.ProductID).ToList();
                whereGallery += " AND " + CreateWhereIN(productid, "productid");

                var data = svProduct.SelectData <b2bProductImage>(" * ", whereGallery);
                foreach (var p in fav)
                {
                    var item = new ProductModel();
                    #region set product model
                    item.productid   = (int)p.ProductID;
                    item.productname = p.ProductName;
                    item.price       = (decimal)p.Price;
                    //item.promotionprice = (p.PromotionPrice > 0) ? (decimal)p.PromotionPrice : 0;
                    //item.ispromotion = (p.IsPromotion != null) ? (bool)p.IsPromotion : false;
                    item.compname      = p.CompName;
                    item.compid        = (int)p.ProductCompID;
                    item.complevel     = (int)p.CompLevel;
                    item.createdate    = p.CreatedDate;
                    item.modifieddate  = p.ModifiedDate;
                    item.imagepath     = p.ProductImgPath;
                    item.productdetail = p.ProductDetail;

                    item.shortdescription = (!string.IsNullOrEmpty(p.ShortDescription))?p.ShortDescription.Replace("~", " "):"";
                    item.isfav            = true;
                    item.gallery          = new List <GalleryModel>();
                    #endregion

                    #region First Image
                    var g = new GalleryModel();
                    g.imageid   = 0;
                    g.imagepath = p.ProductImgPath;
                    item.gallery.Add(g);
                    #endregion

                    if (data != null && data.Count > 0)
                    {
                        foreach (var it in data.Where(m => m.ProductID == p.ProductID))
                        {
                            g           = new GalleryModel();
                            g.imageid   = it.ProductImageID;
                            g.imagepath = it.ImgPath;
                            item.gallery.Add(g);
                        }
                    }
                    product.Add(item);
                }
            }
            #endregion

            return(Json(new { favorites = product, totalrow = svFav.TotalRow, totalpage = svFav.TotalPage }, JsonRequestBehavior.AllowGet));
        }