Esempio n. 1
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));
        }
        public async Task <ActionResult> GetPolicy(string id)
        {
            if (string.IsNullOrWhiteSpace(id))
            {
                return(BuildError(ErrorCodes.InvalidRequestCode, "the identifier must be specified", HttpStatusCode.BadRequest));
            }

            if (!await _representationManager.CheckRepresentationExistsAsync(this, Constants.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, Constants.CachingStoreNames.GetPolicyStoreName + id);

            return(new OkObjectResult(content));
        }