/// <summary>
        /// 用于ProductSearch页面的几个字段的AutoCompleted用(新需求:Millie,Mike)2014年3月7日
        /// </summary>
        /// <param name="term"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public ActionResult GetAutoCompeltedInfo(string term, int type)
        {
            var pss = new ProductSearchServices();

            return(Json(new NBCMSResultJson
            {
                Status = StatusType.OK,
                Data = pss.GetAutoCompeltedInfo(term, type)
            }));
        }
        public JsonResult List(Guid?categoryId, List <Guid> categoryIds, string keywords,
                               int?skip, int?take, string sortField, string orderBy)
        {
            var  xtake = 10;
            var  xskip = 0;
            long total = 0;

            if (skip != null)
            {
                xskip = skip.Value;
            }
            if (take != null)
            {
                xtake = take.Value;
            }
            if (string.IsNullOrEmpty(sortField))
            {
                sortField = nameof(FeNews.CreatedDate);
            }
            if (string.IsNullOrEmpty(orderBy))
            {
                orderBy = "desc";
            }

            List <FeProduct>       rows             = new List <FeProduct>();
            List <ContentLanguage> contentLanguages = null;

            categoryIds = categoryIds ?? new List <Guid>();

            if (categoryId != null && categoryId.Value != Guid.Empty)
            {
                categoryIds.Add(categoryId.Value);
            }
            var producs = ProductSearchServices.Search(keywords, LanguageId, categoryIds, null, xskip, xtake,
                                                       out contentLanguages, out total);

            foreach (var p in producs)
            {
                var i = new FeProduct();
                i.CreatedDate    = p.CreatedDate;
                i.Id             = p.Id;
                i.Price          = p.Price;
                i.ProductCode    = p.ProductCode;
                i.Published      = p.Published;
                i.AllowComment   = p.AllowComment;
                i.Title          = contentLanguages.GetValue(i.Id, "Title");
                i.UrlImage       = contentLanguages.GetValue(i.Id, "UrlImage");
                i.SeoUrlFriendly = contentLanguages.GetValue(i.Id, "SeoUrlFriendly");

                rows.Add(i);
            }

            return(Json(new { total, rows, success = true }, JsonRequestBehavior.AllowGet));
        }
 public FileResult ExportToExcel(string postData, User_Profile_Model useInfo)
 {
     try
     {
         //反序列化客户端传递上来的数据
         var serializer = new JavaScriptSerializer();
         var model      = serializer.Deserialize(postData, typeof(SKU_Query_Model)) as SKU_Query_Model;
         var pcSvr      = new ProductSearchServices();
         var fileName   = pcSvr.ExoprtedSKUDataToServer(model, useInfo);
         var exportPath = System.Web.HttpContext.Current.Server.MapPath("~/MediaLib/");
         var path       = exportPath + fileName;
         return(File(path, "application/ms-txt", fileName));
     }
     catch (Exception ex)
     {
         NBCMSLoggerManager.Error("Message:" + ex.Message);
         NBCMSLoggerManager.Error("Source:" + ex.Source);
         NBCMSLoggerManager.Error("StackTrace:" + ex.StackTrace);
         return(null);
         // return this.ExcelCSV("There is a error has been occur   please contact administrator".ToString(), "Product_Search_Result_Error.csv", "application/ms-txt");
     }
 }
        public JsonResult ListResult(string keywords,
                                     int?skip, int?take, string sortField, string orderBy)
        {
            var  xtake = 10;
            var  xskip = 0;
            long total = 0;

            if (skip != null)
            {
                xskip = skip.Value;
            }
            if (take != null)
            {
                xtake = take.Value;
            }
            if (string.IsNullOrEmpty(sortField))
            {
                sortField = nameof(FeProduct.CreatedDate);
            }
            if (string.IsNullOrEmpty(orderBy))
            {
                orderBy = "desc";
            }

            List <FeProduct> rows = new List <FeProduct>();

            if (!string.IsNullOrEmpty(keywords))
            {
                List <ContentLanguage> contentLanguages = null;

                var tempProduct = ProductSearchServices.Search(keywords, LanguageId, new List <Guid>()
                {
                }, true, xskip, xtake,
                                                               out contentLanguages, out total);

                if (tempProduct.Count == 0)
                {
                    rows.Add(new FeProduct()
                    {
                        Title = "Not found any content match with keywords"
                    });
                }
                else
                {
                    foreach (var p in tempProduct)
                    {
                        var i = new FeProduct();
                        i.CreatedDate      = p.CreatedDate;
                        i.Id               = p.Id;
                        i.ProductCode      = p.ProductCode;
                        i.Price            = p.Price;
                        i.Quantity         = p.Quantity;
                        i.Published        = p.Published;
                        i.Title            = contentLanguages.GetValue(p.Id, "Title");
                        i.ShortDescription = contentLanguages.GetValue(p.Id, "ShortDescription");
                        i.UrlImage         = contentLanguages.GetValue(p.Id, "UrlImage");
                        i.SeoUrlFriendly   = contentLanguages.GetValue(p.Id, "SeoUrlFriendly");

                        rows.Add(i);
                    }
                }
            }
            else
            {
                rows.Add(new FeProduct()
                {
                    Title = "No keywords to search"
                });
            }
            return(Json(new { total, rows, success = true }, JsonRequestBehavior.AllowGet));
        }