Ejemplo n.º 1
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var response = await repository.GetApiScopes(id : id.GetValueOrDefault())
                           .ConfigureAwait(false);

            ApiScope = response.FirstOrDefault();

            if (ApiScope == null)
            {
                return(NotFound());
            }

            return(Page());
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var existing = await repository.GetApiScopes(name : ApiScope.Name)
                           .ConfigureAwait(false);

            if (existing.Any(x => x.Name == ApiScope.Name && x.Id != ApiScope.Id))
            {
                ModelState.AddModelError("DupeName", "This Api Scope name already exists on the system");
                return(Page());
            }

            _ = await repository.StoreApiScope(ApiScope)
                .ConfigureAwait(false);

            return(RedirectToPage("../Api/Details", new { id = ApiScope.ApiResourceId }));
        }
Ejemplo n.º 3
0
        public async Task<IActionResult> OnGetAsync(int? id)
        {
            if (id == null)
            {
                return NotFound();
            }

            var apiTask = repository.GetApiResources(id.GetValueOrDefault());
            var apiScopeTask = repository.GetApiScopes(apiResourceId: id.GetValueOrDefault());

            await Task.WhenAll(apiTask, apiScopeTask)
                .ConfigureAwait(false);

            Api = apiTask.Result.FirstOrDefault();

            if (Api == null)
            {
                return NotFound();
            }

            Api.Scopes = apiScopeTask.Result;

            return Page();
        }