Ejemplo n.º 1
0
        /// <summary>
        ///     List out resource keys and allow editing
        /// </summary>
        /// <returns></returns>
        private async Task <ActionResult> ListResourceKeys(int?page, string search)
        {
            var pageIndex    = page ?? 1;
            var allResources = string.IsNullOrWhiteSpace(search)
                ? await LocalizationService.GetAllResourceKeys(pageIndex, ForumConfiguration.Instance.AdminListPageSize)
                : await LocalizationService.SearchResourceKeys(search, pageIndex,
                                                               ForumConfiguration.Instance.AdminListPageSize);

            // Redisplay list of resources
            var allViewModelResourceKeys = allResources.Select(resource => new LocaleResourceKeyViewModel
            {
                Id        = resource.Id,
                Name      = resource.Name,
                Notes     = resource.Notes,
                DateAdded = resource.DateAdded
            }).ToList();

            var resourceListModel = new ResourceKeyListViewModel
            {
                ResourceKeys = allViewModelResourceKeys,
                PageIndex    = pageIndex,
                TotalCount   = allResources.TotalCount,
                Search       = search,
                TotalPages   = allResources.TotalPages
            };

            return(View("ListKeys", resourceListModel));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// List out resource keys and allow editing
        /// </summary>
        /// <returns></returns>
        private ActionResult ListResourceKeys(int?page, string search)
        {
            using (UnitOfWorkManager.NewUnitOfWork())
            {
                var pageIndex    = page ?? 1;
                var allResources = string.IsNullOrEmpty(search) ? LocalizationService.GetAllResourceKeys(pageIndex, AppConstants.AdminListPageSize) :
                                   LocalizationService.SearchResourceKeys(search, pageIndex, AppConstants.AdminListPageSize);

                // Redisplay list of resources
                var allViewModelResourceKeys = allResources.Select(resource => new LocaleResourceKeyViewModel
                {
                    Id        = resource.Id, Name = resource.Name,
                    Notes     = resource.Notes,
                    DateAdded = resource.DateAdded
                }).ToList();

                var resourceListModel = new ResourceKeyListViewModel
                {
                    ResourceKeys = allViewModelResourceKeys,
                    PageIndex    = pageIndex,
                    TotalCount   = allResources.TotalCount,
                    Search       = search
                };

                return(View("ListKeys", resourceListModel));
            }
        }