コード例 #1
0
ファイル: StoreController.cs プロジェクト: hzl091/BrnShop
        /// <summary>
        /// 店铺搜索
        /// </summary>
        public ActionResult Search()
        {
            //搜索词
            string word = WebHelper.GetQueryString("word");

            if (word.Length == 0)
            {
                return(View("~/mobile/views/shared/prompt.cshtml", new PromptModel(WorkContext.UrlReferrer, "请输入关键词")));
            }

            //异步保存搜索历史
            Asyn.UpdateSearchHistory(WorkContext.Uid, word);

            //判断搜索词是否为店铺分类名称,如果是则重定向到店铺分类页面
            int storeCid = Stores.GetStoreCidByStoreIdAndName(WorkContext.StoreId, word);

            if (storeCid > 0)
            {
                return(Redirect(Url.Action("class", new RouteValueDictionary {
                    { "storeId", WorkContext.StoreId }, { "storeCid", storeCid }
                })));
            }

            //排序列
            int sortColumn = WebHelper.GetQueryInt("sortColumn");
            //排序方向
            int sortDirection = WebHelper.GetQueryInt("sortDirection");
            //当前页数
            int page = WebHelper.GetQueryInt("page");

            //检查当前页数
            if (page < 1)
            {
                page = 1;
            }

            //商品总数量
            int totalCount = 0;
            //商品列表
            List <PartProductInfo> productList = null;

            Searches.SearchStoreProducts(20, page, word, WorkContext.StoreId, storeCid, 0, 0, sortColumn, sortDirection, ref totalCount, ref productList);

            //分页对象
            PageModel pageModel = new PageModel(20, page, totalCount);
            //视图对象
            StoreSearchModel model = new StoreSearchModel()
            {
                Word          = word,
                SortColumn    = sortColumn,
                SortDirection = sortDirection,
                PageModel     = pageModel,
                ProductList   = productList
            };

            return(View(model));
        }
コード例 #2
0
ファイル: StoreModelFactory.cs プロジェクト: hfz-r/mynews-sms
        public async Task <StoreListModel> PrepareStoreListModel(StoreSearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            //get stores
            var stores = await _storeService.GetAllStores(
                storeName : searchModel.SearchStoreName,
                areaCode : searchModel.SearchAreaCode,
                city : searchModel.SearchCity,
                state : searchModel.SearchState,
                pageIndex : searchModel.Page - 1,
                pageSize : searchModel.PageSize);

            var model = new StoreListModel
            {
                Data = stores.Select(store =>
                {
                    var storeModel = store.ToModel <StoreModel>();

                    storeModel.BranchNo       = store.P_BranchNo;
                    storeModel.Name           = store.P_BranchNo + " - " + store.P_Name;
                    storeModel.AreaCode       = store.P_AreaCode;
                    storeModel.Address1       = store.P_Addr1;
                    storeModel.Address2       = store.P_Addr2;
                    storeModel.Address3       = store.P_Addr3;
                    storeModel.City           = store.P_City;
                    storeModel.State          = store.P_State;
                    storeModel.Country        = store.P_Country;
                    storeModel.CountUserStore = store.UserStores.Count;

                    return(storeModel);
                }),
                Total = stores.TotalCount
            };

            if (searchModel.Sort != null && searchModel.Sort.Any())
            {
                foreach (var s in searchModel.Sort)
                {
                    model.Data = await model.Data.Sort(s.Field, s.Dir);
                }
            }

            if (searchModel.Filter != null && searchModel.Filter.Filters != null && searchModel.Filter.Filters.Any())
            {
                var filter = searchModel.Filter;
                model.Data = await model.Data.Filter(filter);

                model.Total = model.Data.Count();
            }

            return(model);
        }
コード例 #3
0
        public async Task <IActionResult> List(StoreSearchModel searchModel)
        {
            if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageUserStore))
            {
                return(AccessDeniedKendoGridJson());
            }

            var model = await _storeModelFactory.PrepareStoreListModel(searchModel);

            return(Json(model));
        }
コード例 #4
0
        /// <summary>
        /// Prepare store search model
        /// </summary>
        /// <param name="searchModel">Store search model</param>
        /// <returns>
        /// A task that represents the asynchronous operation
        /// The task result contains the store search model
        /// </returns>
        public virtual Task <StoreSearchModel> PrepareStoreSearchModelAsync(StoreSearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            //prepare page parameters
            searchModel.SetGridPageSize();

            return(Task.FromResult(searchModel));
        }
コード例 #5
0
        /// <summary>
        /// Prepare store search model
        /// </summary>
        /// <param name="searchModel">Store search model</param>
        /// <returns>Store search model</returns>
        public virtual StoreSearchModel PrepareStoreSearchModel(StoreSearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            //prepare page parameters
            searchModel.SetGridPageSize();

            return(searchModel);
        }
コード例 #6
0
        public virtual IActionResult List(StoreSearchModel searchModel)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageStores))
            {
                return(AccessDeniedDataTablesJson());
            }

            //prepare model
            var model = _storeModelFactory.PrepareStoreListModel(searchModel);

            return(Json(model));
        }
コード例 #7
0
        public virtual async Task <IActionResult> List(StoreSearchModel searchModel)
        {
            if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageStores))
            {
                return(await AccessDeniedDataTablesJson());
            }

            //prepare model
            var model = await _storeModelFactory.PrepareStoreListModelAsync(searchModel);

            return(Json(model));
        }
コード例 #8
0
        public IActionResult StoresList(StoreSearchModel searchModel)
        {
            Expression <Func <Store, bool> > storeWhere = x => true;

            if (!searchModel.SearchPhrase.IsNullEmptyOrWhiteSpace())
            {
                storeWhere = store => store.Name.StartsWith(searchModel.SearchPhrase);
            }

            var stores = _storeService.Get(out int totalResults, storeWhere, store => store.Id, RowOrder.Ascending, searchModel.Current, searchModel.RowCount);

            var models = stores.Select(_storeModelFactory.Create).ToList();

            return(R.Success.With("stores", models)
                   .WithGridResponse(totalResults, searchModel.Current, searchModel.RowCount)
                   .Result);
        }
コード例 #9
0
ファイル: StoreModelFactory.cs プロジェクト: hfz-r/mynews-sms
        public async Task <StoreSearchModel> PrepareStoreSearchModel(StoreSearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            await _baseModelFactory.PrepareStoreAreaCodes(searchModel.AvailableAreaCodes);

            await _baseModelFactory.PrepareStoreCities(searchModel.AvailableCities);

            await _baseModelFactory.PrepareStoreStates(searchModel.AvailableStates);

            searchModel.SetGridPageSize();

            return(searchModel);
        }
コード例 #10
0
        /// <summary>保存店铺搜索
        /// </summary>
        /// <param name="ModuleJson"></param>
        /// <param name="key"></param>
        public void SaveStoreSearch(JsonObject ModuleJson, string key)
        {
            if (!CheckJson(ModuleJson))
            {
                DeleteByKey(key);
                return;
            }
            var item = new StoreSearchModel();

            item.ModuleId          = ModuleJson["ModuleID"].Value;
            item.IsSHowTitle       = ModuleJson["IsShowTitle"].ToBool(false);
            item.ModuleTag         = ModuleJson["ModuleTag"].Value;
            item.ModuleTitel       = ModuleJson["ModuleTitle"].Value;
            item.IsShowPriceFilter = ModuleJson["IsShowPriceFilter"].ToBool(false);
            item.HotWord           = EasyJson.ToJsonString(ModuleJson["LinkList"]);

            CN100.Redis.Client.RedisClientUtility.SetData <StoreSearchModel>(key, item);
        }
コード例 #11
0
        /// <summary>
        /// 店铺搜索
        /// </summary>
        public ActionResult Search()
        {
            //搜索词
            string keyword = WebHelper.GetQueryString("keyword");

            if (keyword.Length > 0 && !SecureHelper.IsSafeSqlString(keyword))
            {
                return(View("~/mobile/views/shared/prompt.cshtml", new PromptModel(WorkContext.UrlReferrer, "您搜索的商品不存在")));
            }

            //判断搜索词是否为店铺分类名称,如果是则重定向到店铺分类页面
            int storeCid = Stores.GetStoreCidByStoreIdAndName(WorkContext.StoreId, keyword);

            if (storeCid > 0)
            {
                return(Redirect(Url.Action("class", new RouteValueDictionary {
                    { "storeId", WorkContext.StoreId }, { "storeCid", storeCid }
                })));
            }

            //排序列
            int sortColumn = WebHelper.GetQueryInt("sortColumn");
            //排序方向
            int sortDirection = WebHelper.GetQueryInt("sortDirection");
            //当前页数
            int page = WebHelper.GetQueryInt("page");

            //分页对象
            PageModel pageModel = new PageModel(20, page, Searches.GetSearchStoreProductCount(keyword, WorkContext.StoreId, 0, 0, 0));
            //视图对象
            StoreSearchModel model = new StoreSearchModel()
            {
                Word          = keyword,
                SortColumn    = sortColumn,
                SortDirection = sortDirection,
                PageModel     = pageModel,
                ProductList   = Searches.SearchStoreProducts(pageModel.PageSize, pageModel.PageNumber, keyword, WorkContext.StoreId, 0, 0, 0, sortColumn, sortDirection)
            };

            //异步保存搜索历史
            Asyn.UpdateSearchHistory(WorkContext.Uid, keyword);

            return(View(model));
        }
コード例 #12
0
        /// <summary>
        /// Prepare paged store list model
        /// </summary>
        /// <param name="searchModel">Store search model</param>
        /// <returns>
        /// A task that represents the asynchronous operation
        /// The task result contains the store list model
        /// </returns>
        public virtual async Task <StoreListModel> PrepareStoreListModelAsync(StoreSearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            //get stores
            var stores = (await _storeService.GetAllStoresAsync()).ToPagedList(searchModel);

            //prepare list model
            var model = new StoreListModel().PrepareToGrid(searchModel, stores, () =>
            {
                //fill in model values from the entity
                return(stores.Select(store => store.ToModel <StoreModel>()));
            });

            return(model);
        }
コード例 #13
0
        /// <summary>
        /// Prepare paged store list model
        /// </summary>
        /// <param name="searchModel">Store search model</param>
        /// <returns>Store list model</returns>
        public virtual StoreListModel PrepareStoreListModel(StoreSearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            //get stores
            var stores = _storeService.GetAllStores(loadCacheableCopy: false);

            //prepare list model
            var model = new StoreListModel
            {
                //fill in model values from the entity
                Data  = stores.PaginationByRequestModel(searchModel).Select(store => store.ToModel <StoreModel>()),
                Total = stores.Count
            };

            return(model);
        }
コード例 #14
0
ファイル: StoreModelFactory.cs プロジェクト: agsyazilim/Ags
 public StoreListModel PrepareStoreListModel(StoreSearchModel searchModel)
 {
     throw new NotImplementedException();
 }
コード例 #15
0
        /// <summary>保存店铺搜索
        /// </summary>
        /// <param name="ModuleJson"></param>
        /// <param name="key"></param>
        public void SaveStoreSearch(JsonObject ModuleJson, string key)
        {
            if (!CheckJson(ModuleJson))
            {
                DeleteByKey(key);
                return;
            }
            var item = new StoreSearchModel();
            item.ModuleId = ModuleJson["ModuleID"].Value;
            item.IsSHowTitle = ModuleJson["IsShowTitle"].ToBool(false);
            item.ModuleTag = ModuleJson["ModuleTag"].Value;
            item.ModuleTitel = ModuleJson["ModuleTitle"].Value;
            item.IsShowPriceFilter = ModuleJson["IsShowPriceFilter"].ToBool(false);
            item.HotWord = EasyJson.ToJsonString(ModuleJson["LinkList"]);

            CN100.Redis.Client.RedisClientUtility.SetData<StoreSearchModel>(key, item);

        }