Example #1
0
        public async Task <IActionResult> GetByFilter([FromQuery] CredentialFilter filter)
        {
            var validationResult = new CredentialFilterValidator().Validate(filter);

            validationResult.AddToModelState(this.ModelState, null);

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

            var page = await CredentialStore.Get(filter);

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

            var vmList = new List <CredentialVM>();

            foreach (Credential credential in page.Items)
            {
                var newVm = new CredentialVM(credential);
                vmList.Add(newVm);
            }

            return(Collection <Credential>(filter, page.Total, vmList));
        }
Example #2
0
        public async Task <IActionResult> GetByCredentialId([GetterParameter][FromRoute] string credentialId)
        {
            if (string.IsNullOrEmpty(credentialId))
            {
                return(BadRequest());
            }

            Credential credential = await this.CredentialStore.Get(credentialId);

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

            CredentialVM vm = new CredentialVM(credential);

            return(Element <Credential>(vm));
        }