public static CreateOrganizationResponse Unmarshall(UnmarshallerContext context)
        {
            CreateOrganizationResponse createOrganizationResponse = new CreateOrganizationResponse();

            createOrganizationResponse.HttpResponse = context.HttpResponse;
            createOrganizationResponse.RequestId    = context.StringValue("CreateOrganization.RequestId");
            createOrganizationResponse.Success      = context.BooleanValue("CreateOrganization.Success");
            createOrganizationResponse.ErrorCode    = context.IntegerValue("CreateOrganization.ErrorCode");

            CreateOrganizationResponse.CreateOrganization_Result result = new CreateOrganizationResponse.CreateOrganization_Result();
            result.OrganizationId             = context.StringValue("CreateOrganization.Result.OrganizationId");
            result.Name                       = context.StringValue("CreateOrganization.Result.Name");
            result.RegionId                   = context.StringValue("CreateOrganization.Result.RegionId");
            result.ZoneId                     = context.StringValue("CreateOrganization.Result.ZoneId");
            result.CodeName                   = context.StringValue("CreateOrganization.Result.CodeName");
            result.Domain                     = context.StringValue("CreateOrganization.Result.Domain");
            result.Description                = context.StringValue("CreateOrganization.Result.Description");
            result.OwnerBid                   = context.StringValue("CreateOrganization.Result.OwnerBid");
            result.OwnerUid                   = context.IntegerValue("CreateOrganization.Result.OwnerUid");
            result.OwnerName                  = context.StringValue("CreateOrganization.Result.OwnerName");
            result.PeerCount                  = context.IntegerValue("CreateOrganization.Result.PeerCount");
            result.UserCount                  = context.IntegerValue("CreateOrganization.Result.UserCount");
            result.ConsortiumCount            = context.IntegerValue("CreateOrganization.Result.ConsortiumCount");
            result.SpecName                   = context.StringValue("CreateOrganization.Result.SpecName");
            result.RequestId                  = context.StringValue("CreateOrganization.Result.RequestId");
            result.CreateTime                 = context.StringValue("CreateOrganization.Result.CreateTime");
            result.ClusterState               = context.StringValue("CreateOrganization.Result.ClusterState");
            result.ServiceState               = context.StringValue("CreateOrganization.Result.ServiceState");
            createOrganizationResponse.Result = result;

            return(createOrganizationResponse);
        }
示例#2
0
        public async Task <CreateOrganizationResponse> CreateOrganizationAsync(CreateOrganizationRequest request, ClaimsPrincipal claim)
        {
            log?.LogDebug("Request creating an organization!");

            var response = new CreateOrganizationResponse();

            if (claim == null || claim.Identity == null || string.IsNullOrEmpty(claim.Identity.Name))
            {
                response.Status = CreateOrganizationResponse.CreateOrgaStatusCodes.Error;
                log?.LogDebug($"The given claim was not valid.");
                return(response);
            }

            log?.LogInformation($"{claim.Identity.Name} wants to create the organization {request.Name}");

            var user = await userManager.GetUserAsync(claim);

            if (user == null)
            {
                response.Status = CreateOrganizationResponse.CreateOrgaStatusCodes.Error;
                log?.LogDebug($"User was not found to create the organization.");
                return(response);
            }

            if (!IsNameAvailable(request.Name))
            {
                response.Status = CreateOrganizationResponse.CreateOrgaStatusCodes.NameTaken;
                log?.LogDebug($"Organization Name: {request.Name} was already taken!");
                return(response);
            }

            if (!IsShortAvailable(request.ShortName))
            {
                response.Status = CreateOrganizationResponse.CreateOrgaStatusCodes.ShortTaken;
                log?.LogDebug($"Organization Short: {request.ShortName} was already taken!");
                return(response);
            }

            var createdOrganization = CreateOrganization(request.Name, request.ShortName, user);

            if (createdOrganization != null)
            {
                response.OrganizationId = createdOrganization.OrganizationId;
                log?.LogDebug($"Organization {request.Name} with the id {createdOrganization.OrganizationId} has been created!");
            }
            return(response);
        }
示例#3
0
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            CreateOrganizationResponse response = new CreateOrganizationResponse();

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

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

            return(response);
        }