Ejemplo n.º 1
0
        // --------------
        // Index
        // --------------

        public async Task <IActionResult> Index(TenantIndexOptions opts)
        {
            // Ensure we have permission
            if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageTenants))
            {
                return(Unauthorized());
            }

            // Ensure host
            if (!_shellSettings.IsDefaultShell())
            {
                return(Unauthorized());
            }

            if (opts == null)
            {
                opts = new TenantIndexOptions();
            }

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

            // Build view model
            var viewModel = new TenantIndexViewModel()
            {
                Options = opts
            };

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

            // Return view
            return(View((LayoutViewModel)await _viewProvider.ProvideIndexAsync(new ShellSettings(), this)));
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> Index()
        {
            try
            {
                var requestUri = $"{WebApiBaseUrl}{TenantGetAllEndPoint}";
                HttpResponseMessage httpResponseMessage = await HttpRequestFactory.Get(requestUri);

                var response = httpResponseMessage.ContentAsType <ApiResponse>();
                if (response.StatusCode == HttpStatusCode.OK)
                {
                    var output = JsonConvert.DeserializeObject <List <TenantDto> >(response.Data.ToString());
                    var model  = new TenantIndexViewModel(output);
                    return(View(model));
                }
                return(null);
            }

            catch (Exception ex)
            {
                throw ex;
            }
        }