Exemple #1
0
        public async Task <ActionResult <DefaultResponse <bool> > > SaveScope([FromBody] SaveApiScopeViewModel model)
        {
            if (!ModelState.IsValid)
            {
                NotifyModelStateErrors();
                return(Response(false));
            }
            await _apiResourceAppService.SaveScope(model);

            return(Response(true));
        }
        public async Task ShouldAddNewApiScope()
        {
            var command = ApiResourceFaker.GenerateApiResource().Generate();

            await _apiResourceAppService.Save(command);

            var scope = ApiResourceFaker.GenerateSaveScopeViewModer(command.Name).Generate();

            await _apiResourceAppService.SaveScope(scope);

            _database.ApiResources.FirstOrDefault(f => f.Name == command.Name).Should().NotBeNull();
            _database.ApiScopes.Include(i => i.ApiResource).Where(f => f.ApiResource.Name == command.Name).Should().NotBeNull();
        }
        public async Task <ActionResult <IEnumerable <Scope> > > SaveScope(string resource, [FromBody] SaveApiScopeViewModel model)
        {
            if (!ModelState.IsValid)
            {
                NotifyModelStateErrors();
                return(ModelStateErrorResponseError());
            }

            model.ResourceName = resource;
            await _apiResourceAppService.SaveScope(model);

            var scopes = await _apiResourceAppService.GetScopes(resource);

            return(ResponsePost(nameof(Scopes), new { resource }, scopes));
        }