コード例 #1
0
        public IActionResult List(string database, int assetTypeId)
        {
            IActionResult action()
            {
                Guid           databaseId = ParseGuid(database);
                AssetListInfo  assets     = this.Api.DataBase.GetAssetsOfType(databaseId, assetTypeId);
                AssetListModel model      = new AssetListModel(this.Api, assets);

                return(View(model));
            }

            return(this.SafePerformAction(action));
        }
コード例 #2
0
        public async Task <IActionResult> AssetList(DataSourceRequest command,
                                                    AssetListModel model)
        {
            model.ClientId = (int)_workContext.CurrentCustomer.ClientId;
            var(assetListModel, totalCount) = await _assetService.PrepareAssetListModel(model, command.Page, command.PageSize);

            var gridModel = new DataSourceResult
            {
                Data  = assetListModel.ToList(),
                Total = totalCount
            };

            return(Json(gridModel));
        }
コード例 #3
0
        public async Task <IActionResult> AssetList()
        {
            var model = new AssetListModel();

            var categories = await _productMangement.GetAssetCategories((int)_workContext.CurrentCustomer.ClientId);

            model.AvailableCategory.Add(new SelectListItem {
                Text = "All", Value = "All"
            });

            foreach (var item in categories)
            {
                model.AvailableCategory.Add(new SelectListItem {
                    Text = item.AssetCategory1, Value = item.AssetCategoryId.ToString()
                });
            }

            return(View(model));
        }
コード例 #4
0
        public async Task <(IEnumerable <AssetModel> AssetModelList, int totalCount)> PrepareAssetListModel(AssetListModel model, int pageIndex, int pageSize)
        {
            try
            {
                SqlParameter[] pr = new SqlParameter[]
                {
                    new SqlParameter("@intClientID", (int)_workContext.CurrentCustomer.ClientId),

                    new SqlParameter("@DateBegin", (string.IsNullOrEmpty(model.SearchByStartDate)) ? DBNull.Value.ToString() : model.SearchByStartDate),

                    new SqlParameter("@DateEnd", (string.IsNullOrEmpty(model.SearchByEndDate)) ? DBNull.Value.ToString() : model.SearchByEndDate),

                    new SqlParameter("@intSearchFor", model.SearchFor),

                    new SqlParameter("@txtSearchFor", (string.IsNullOrEmpty(model.SearchTerm)) ? DBNull.Value.ToString() : model.SearchTerm),

                    new SqlParameter("@intSort", model.SortBy),
                    new SqlParameter("@DateType", model.SearchByDate),
                    new SqlParameter("@txtCategory", model.SearchByCategory)
                };

                var assetList = await _dbContext.Set <AssetExport>().FromSqlRaw("exec AssetExport @intClientID,@DateBegin,@DateEnd,@intSearchFor,@txtSearchFor,@intSort,@DateType,@txtCategory", pr).ToListAsync();

                var assetListModel = _mapper.Map <List <AssetModel> >(assetList);

                int totalCount = assetListModel.Count;
                int pageOffSet = (Convert.ToInt32(pageIndex) - 1) * 10;
                assetListModel = assetListModel.Skip(pageOffSet).Take(Convert.ToInt32(pageSize)).ToList();

                return(assetListModel, totalCount);
            }
            catch (Exception ex)
            {
            }

            return(null, 0);
        }