Example #1
0
        public async Task <IActionResult> Roles([FromRoute] string credentialId, [FromQuery] CredentialRoleFilter filter)
        {
            if (string.IsNullOrEmpty(credentialId))
            {
                return(NotFound());
            }

            var validationResult = new CredentialRoleFilterValidator().Validate(filter);

            validationResult.AddToModelState(this.ModelState, null);

            if (!validationResult.IsValid)
            {
                return(ValidationError());
            }

            var page = await CredentialStore.GetRoles(credentialId, filter);

            if (page.IsEmpty)
            {
                return(NotFound <CredentialRole>(filter, page));
            }

            return(Collection <CredentialRole>(filter, page));
        }