예제 #1
0
        public JsonResult ChangeSettings(FileSettingsViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Json(ModelState.ToErrorModel <FileSettingsViewModel>()));
            }

            if (model.TenantId == Guid.Empty)
            {
                model.TenantId = _userManager.CurrentUserTenantId ?? Guid.Empty;
            }

            var response = _fileManager.ChangeSettings(model);

            return(Json(response));
        }
예제 #2
0
        // ---------------
        // Settings
        // ---------------

        public async Task <IActionResult> Settings(RoleIndexOptions opts, PagerOptions pager)
        {
            // Ensure we have permission
            if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageFileSettings))
            {
                return(Unauthorized());
            }

            _breadCrumbManager.Configure(builder =>
            {
                builder.Add(S["Home"], home => home
                            .Action("Index", "Admin", "Plato.Admin")
                            .LocalNav()
                            ).Add(S["Files"], manage => manage
                                  .Action("Index", "Admin", "Plato.Files")
                                  .LocalNav()
                                  ).Add(S["Settings"]);
            });

            // default options
            if (opts == null)
            {
                opts = new RoleIndexOptions();
            }

            // default pager
            if (pager == null)
            {
                pager = new PagerOptions();
            }

            // Get default options
            var defaultViewOptions  = new RoleIndexOptions();
            var defaultPagerOptions = new PagerOptions();

            // Add non default route data for pagination purposes
            if (opts.Search != defaultViewOptions.Search)
            {
                this.RouteData.Values.Add("opts.search", opts.Search);
            }
            if (opts.Sort != defaultViewOptions.Sort)
            {
                this.RouteData.Values.Add("opts.sort", opts.Sort);
            }
            if (opts.Order != defaultViewOptions.Order)
            {
                this.RouteData.Values.Add("opts.order", opts.Order);
            }
            if (pager.Page != defaultPagerOptions.Page)
            {
                this.RouteData.Values.Add("pager.page", pager.Page);
            }
            if (pager.Size != defaultPagerOptions.Size)
            {
                this.RouteData.Values.Add("pager.size", pager.Size);
            }

            // Build view model
            var viewModel = new FileSettingsViewModel()
            {
                Options = opts,
                Pager   = pager
            };

            // Add view model to context
            this.HttpContext.Items[typeof(FileSettingsViewModel)] = viewModel;

            // Return view
            return(View((LayoutViewModel)await _settingsViewProvider.ProvideIndexAsync(new FileSetting(), this)));
        }