Ejemplo n.º 1
0
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context)
        {
            AddPermissionResponse response = new AddPermissionResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.IsStartElement)
                {
                    if (context.TestExpression("AddPermissionResult", 2))
                    {
                        UnmarshallResult(context, response);
                        continue;
                    }

                    if (context.TestExpression("ResponseMetadata", 2))
                    {
                        response.ResponseMetadata = ResponseMetadataUnmarshaller.Instance.Unmarshall(context);
                    }
                }
            }

            return(response);
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> PostPermissions([FromBody] IEnumerable <PostPermission> postPermissions)
        {
            if (postPermissions == null)
            {
                return(BuildError(ErrorCodes.InvalidRequestCode, "no parameter in body request", HttpStatusCode.BadRequest));
            }

            var parameters = postPermissions.Select(p => p.ToParameter());
            var clientId   = this.GetClientId();

            if (string.IsNullOrWhiteSpace(clientId))
            {
                return(BuildError(ErrorCodes.InvalidRequestCode, "the client_id cannot be extracted", HttpStatusCode.BadRequest));
            }

            var ticketId = await _permissionControllerActions.Add(parameters, clientId);

            var result = new AddPermissionResponse
            {
                TicketId = ticketId
            };

            return(new ObjectResult(result)
            {
                StatusCode = (int)HttpStatusCode.Created
            });
        }
        public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context)
        {
            AddPermissionResponse response = new AddPermissionResponse();

            while (context.Read())
            {
                if (context.IsStartElement)
                {
                    if (context.TestExpression("ResponseMetadata", 2))
                    {
                        response.ResponseMetadata = ResponseMetadataUnmarshaller.GetInstance().Unmarshall(context);
                    }
                }
            }


            return(response);
        }
Ejemplo n.º 4
0
        private static void UnmarshallResult(XmlUnmarshallerContext context, AddPermissionResponse response)
        {
            int originalDepth = context.CurrentDepth;
            int targetDepth   = originalDepth + 1;

            if (context.IsStartOfDocument)
            {
                targetDepth += 2;
            }

            while (context.ReadAtDepth(originalDepth))
            {
                if (context.IsStartElement || context.IsAttribute)
                {
                }
            }

            return;
        }
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            AddPermissionResponse response = new AddPermissionResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("Statement", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.Statement = unmarshaller.Unmarshall(context);
                    continue;
                }
            }

            return(response);
        }
        public async Task <ActionResult> PostPermission([FromBody] PostPermission postPermission)
        {
            if (postPermission == null)
            {
                throw new ArgumentNullException(nameof(postPermission));
            }

            var parameter = postPermission.ToParameter();
            var clientId  = this.GetClientId();
            var ticketId  = await _permissionControllerActions.Add(parameter, clientId);

            var result = new AddPermissionResponse
            {
                TicketId = ticketId
            };

            return(new ObjectResult(result)
            {
                StatusCode = (int)HttpStatusCode.Created
            });
        }
        public async Task <ActionResult> PostPermissions([FromBody] IEnumerable <PostPermission> postPermissions)
        {
            if (postPermissions == null)
            {
                return(BuildError(ErrorCodes.InvalidRequestCode, "no parameter in body request", HttpStatusCode.BadRequest));
            }

            var audiences  = GetAudiences();
            var parameters = postPermissions.Select(p => p.ToParameter());
            var ticketId   = await _permissionControllerActions.Add(audiences, parameters);

            var result = new AddPermissionResponse
            {
                TicketId = ticketId
            };

            return(new ObjectResult(result)
            {
                StatusCode = (int)HttpStatusCode.Created
            });
        }