public IActionResult Resources(string languageId, DataSourceRequest command,
                                       LanguageResourceFilterModel model)
        {
            var resources = _languageViewModelService.PrepareLanguageResourceModel(model, languageId, command.Page, command.PageSize);
            var gridModel = new DataSourceResult
            {
                Data  = resources.languageResourceModels.ToList(),
                Total = resources.totalCount
            };

            return(Json(gridModel));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Resources(string languageId, DataSourceRequest command,
                                                    LanguageResourceFilterModel model)
        {
            var(languageResourceModels, totalCount) = await _languageViewModelService.PrepareLanguageResourceModel(model, languageId, command.Page, command.PageSize);

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

            return(Json(gridModel));
        }
Ejemplo n.º 3
0
        public IActionResult Resources(string languageId, DataSourceRequest command,
                                       LanguageResourceFilterModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageLanguages))
            {
                return(AccessDeniedView());
            }

            var language = _languageService.GetLanguageById(languageId);

            var resources = _localizationService
                            .GetAllResources(languageId)
                            .OrderBy(x => x.ResourceName)
                            .Select(x => new LanguageResourceModel
            {
                LanguageId = languageId,
                Id         = x.Id,
                Name       = x.ResourceName,
                Value      = x.ResourceValue,
            });

            if (model != null)
            {
                if (!string.IsNullOrEmpty(model.ResourceName))
                {
                    resources = resources.Where(x => x.Name.ToLowerInvariant().Contains(model.ResourceName.ToLowerInvariant()));
                }
                if (!string.IsNullOrEmpty(model.ResourceValue))
                {
                    resources = resources.Where(x => x.Value.ToLowerInvariant().Contains(model.ResourceValue.ToLowerInvariant()));
                }
            }
            resources = resources.AsQueryable();

            var gridModel = new DataSourceResult
            {
                Data  = resources.PagedForCommand(command),
                Total = resources.Count()
            };

            return(Json(gridModel));
        }
Ejemplo n.º 4
0
        public virtual (IEnumerable <LanguageResourceModel> languageResourceModels, int totalCount) PrepareLanguageResourceModel(LanguageResourceFilterModel model, string languageId, int pageIndex, int pageSize)
        {
            var language = _languageService.GetLanguageById(languageId);

            var resources = _localizationService
                            .GetAllResources(languageId)
                            .OrderBy(x => x.ResourceName)
                            .Select(x => new LanguageResourceModel
            {
                LanguageId = languageId,
                Id         = x.Id,
                Name       = x.ResourceName,
                Value      = x.ResourceValue,
            });

            if (model != null)
            {
                if (!string.IsNullOrEmpty(model.ResourceName))
                {
                    resources = resources.Where(x => x.Name.ToLowerInvariant().Contains(model.ResourceName.ToLowerInvariant()));
                }
                if (!string.IsNullOrEmpty(model.ResourceValue))
                {
                    resources = resources.Where(x => x.Value.ToLowerInvariant().Contains(model.ResourceValue.ToLowerInvariant()));
                }
            }
            resources = resources.AsQueryable();
            return(resources.Skip((pageIndex - 1) * pageSize).Take(pageSize), resources.Count());
        }