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

            var validationResult = new SessionFilterValidator(DisplayNameRule).Validate(filter);

            validationResult.AddToModelState(this.ModelState, null);

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

            var sessionsPage = await CredentialStore.GetSessions(credentialId, filter);

            if (sessionsPage.IsEmpty)
            {
                return(NotFound <Session>(filter, sessionsPage));
            }

            return(Collection <Session>(filter, sessionsPage));
        }