Beispiel #1
0
        string MapUserForRequest(UserUpdate user)
        {
            var parameters = new List <string>();

            if (!string.IsNullOrWhiteSpace(user.Email))
            {
                parameters.Add("\"email\" : \"" + user.Email + "\"");
            }

            if (!string.IsNullOrWhiteSpace(user.FamilyName) ||
                !string.IsNullOrWhiteSpace(user.GivenName))
            {
                var name = "\"name\" :{ ";

                var familyName = string.Empty;
                if (!string.IsNullOrWhiteSpace(user.FamilyName))
                {
                    familyName = "\"familyName\" : \"" + user.FamilyName + "\"";
                }

                name += familyName;

                if (!string.IsNullOrWhiteSpace(user.GivenName))
                {
                    if (!string.IsNullOrWhiteSpace(familyName))
                    {
                        name += ",";
                    }

                    name += "\"givenName\" : \"" + user.GivenName + "\"";
                }

                name += "}";

                parameters.Add(name);
            }

            if (user.Active.HasValue)
            {
                parameters.Add(string.Format(@"""active"" : ""{0}""", user.Active.Value ? "true" : "false"));
            }

            if (user.SendInvite.HasValue)
            {
                parameters.Add(string.Format(@"""sendInvite"" : ""{0}""", user.SendInvite.Value ? "true" : "false"));
            }

            if (user.AuthType.HasValue)
            {
                parameters.Add("\"authType\" : \"" + MapAuthType(user.AuthType.Value) + "\"");
            }

            if (user.UserType.HasValue)
            {
                parameters.Add("\"userType\" : \"" + MapUserType(user.UserType.Value) + "\"");
            }

            if (!string.IsNullOrWhiteSpace(user.IdpUserId))
            {
                parameters.Add("\"idpUserId\" : \"" + user.IdpUserId + "\"");
            }

            if (!string.IsNullOrWhiteSpace(user.UserPrincipalName))
            {
                parameters.Add("\"userPrincipalName\" : \"" + user.UserPrincipalName + "\"");
            }

            var content = "{" + string.Join(",", parameters) + "}";

            return(content);
        }