public async Task <ActionResult> Get(string id)
        {
            if (string.IsNullOrWhiteSpace(id))
            {
                throw new ArgumentNullException(nameof(id));
            }

            if (!await _representationManager.CheckRepresentationExistsAsync(this, GetClaimStoreName + id))
            {
                return(new ContentResult
                {
                    StatusCode = 412
                });
            }

            var result = await _claimActions.Get(id);

            if (result == null)
            {
                return(new NotFoundResult());
            }

            var response = result.ToDto();
            await _representationManager.AddOrUpdateRepresentationAsync(this, GetClaimStoreName + id);

            return(new OkObjectResult(response));
        }
Example #2
0
        public async Task <ActionResult> GetPolicy(string id)
        {
            if (string.IsNullOrWhiteSpace(id))
            {
                throw new ArgumentNullException(id);
            }

            if (!await _representationManager.CheckRepresentationExistsAsync(this, CachingStoreNames.GetPolicyStoreName + id))
            {
                return(new ContentResult
                {
                    StatusCode = 412
                });
            }

            var result = await _policyActions.GetPolicy(id);

            if (result == null)
            {
                return(GetNotFoundPolicy());
            }

            var content = result.ToResponse();
            await _representationManager.AddOrUpdateRepresentationAsync(this, CachingStoreNames.GetPolicyStoreName + id);

            return(new OkObjectResult(content));
        }
Example #3
0
        public async Task<ActionResult> GetAll()
        {
            if (!await _representationManager.CheckRepresentationExistsAsync(this, GetClientsStoreName))
            {
                return new ContentResult
                {
                    StatusCode = 412
                };
            }

            var result =  (await _clientActions.GetClients()).ToDtos();
            await _representationManager.AddOrUpdateRepresentationAsync(this, GetClientsStoreName);
            return new OkObjectResult(result);
        }
        public async Task <ActionResult> Get()
        {
            if (!await _representationManager.CheckRepresentationExistsAsync(this, StoreNames.GetResourceOwners))
            {
                return(new ContentResult
                {
                    StatusCode = 412
                });
            }

            var content = (await _resourceOwnerActions.GetResourceOwners()).ToDtos();
            await _representationManager.AddOrUpdateRepresentationAsync(this, StoreNames.GetResourceOwners);

            return(new OkObjectResult(content));
        }
Example #5
0
        public async Task <ActionResult> GetResourceSets()
        {
            if (!await _representationManager.CheckRepresentationExistsAsync(this, CachingStoreNames.GetResourcesStoreName))
            {
                return(new ContentResult
                {
                    StatusCode = 412
                });
            }

            var resourceSetIds = await _resourceSetActions.GetAllResourceSet();

            await _representationManager.AddOrUpdateRepresentationAsync(this, CachingStoreNames.GetResourcesStoreName);

            return(new OkObjectResult(resourceSetIds));
        }
        public async Task <ActionResult> GetResourceSet(string id)
        {
            if (string.IsNullOrWhiteSpace(id))
            {
                return(BuildError(ErrorCodes.InvalidRequestCode, "the identifier must be specified", HttpStatusCode.BadRequest));
            }

            if (!await _representationManager.CheckRepresentationExistsAsync(this, Constants.CachingStoreNames.GetResourceStoreName + id))
            {
                return(new ContentResult
                {
                    StatusCode = 412
                });
            }

            var result = await _resourceSetActions.GetResourceSet(id);

            if (result == null)
            {
                return(GetNotFoundResourceSet());
            }

            var content = result.ToResponse();
            await _representationManager.AddOrUpdateRepresentationAsync(this, Constants.CachingStoreNames.GetResourceStoreName + id);

            return(new OkObjectResult(content));
        }
        public async Task <IActionResult> Put([FromBody] Customer customer)
        {
            if (!await _representationManager.CheckRepresentationExistsAsync(this, EntityName + customer.CustomerId))
            {
                return(new ContentResult
                {
                    StatusCode = 412
                });
            }

            // Update the customer & update the representation
            await _representationManager.AddOrUpdateRepresentationAsync(this, EntityName + customer.CustomerId);

            return(NoContent());
        }
Example #8
0
        private async Task <ActionResult> GetUser(string id)
        {
            if (!await _representationManager.CheckRepresentationExistsAsync(this, string.Format(UsersName, id)))
            {
                return(new ContentResult
                {
                    StatusCode = 412
                });
            }

            var result = await _usersAction.GetUser(id, GetLocationPattern());

            if (result.IsSucceed())
            {
                await _representationManager.AddOrUpdateRepresentationAsync(this, string.Format(UsersName, result.Id), result.Version, true);
            }

            return(this.GetActionResult(result));
        }
        public async Task <ActionResult> GetGroup(string id)
        {
            if (string.IsNullOrWhiteSpace(id))
            {
                throw new ArgumentNullException(nameof(id));
            }

            if (!await _representationManager.CheckRepresentationExistsAsync(this, string.Format(GroupsName, id)))
            {
                return(new ContentResult
                {
                    StatusCode = 412
                });
            }

            var result = await _groupsAction.GetGroup(id, GetLocationPattern(), Request.Query);

            if (result.IsSucceed())
            {
                await _representationManager.AddOrUpdateRepresentationAsync(this, string.Format(GroupsName, result.Id), result.Version, true);
            }

            return(this.GetActionResult(result));
        }