コード例 #1
0
 public static ObjectRequest CreateAddUserRequest(UpdatableUserObject data)
 {
     var request = CreateUserObjectRequest("Add User", Method.POST);
     var updates = BuildJsonUpdateDict(data);
     request.Data = updates;
     return request;
 }
コード例 #2
0
 internal bool EqualsCompletely(UpdatableUserObject other)
 {
     return(
         String.Equals(UserName, other.UserName) &&
         String.Equals(FamilyName, other.FamilyName) &&
         String.Equals(GivenName, other.GivenName) &&
         String.Equals(EMail, other.EMail) &&
         String.Equals(Language, other.Language) &&
         String.Equals(Role, other.Role) &&
         MaxSpace.Equals(other.MaxSpace)
         );
 }
コード例 #3
0
 internal bool EqualsCompletely(UpdatableUserObject other)
 {
     return (
         String.Equals(UserName, other.UserName) &&
         String.Equals(FamilyName, other.FamilyName) &&
         String.Equals(GivenName, other.GivenName) &&
         String.Equals(EMail, other.EMail) &&
         String.Equals(Language, other.Language) &&
         String.Equals(Role, other.Role) &&
         MaxSpace.Equals(other.MaxSpace)
     );
 }
コード例 #4
0
        private static Dictionary<string, object> BuildJsonUpdateDict(UpdatableUserObject userObject)
        {
            var updates = new Dictionary<string, object>();
            var type = userObject.GetType();

            foreach (var pair in JsonUpdatePropertyMap)
            {
                object value = type.GetProperty(pair.Key).GetValue(userObject, null);
                if (value != null)
                {
                    updates[pair.Value] = value;
                }
            }
            return updates;
        }
コード例 #5
0
 public static ObjectRequest CreateEditUserRequest(long id, UpdatableUserObject data)
 {
     var request = CreateUserObjectRequest("Edit User", Method.PUT);
     var updates = BuildJsonUpdateDict(data);
     updates["id"] = id;
     request.Data = updates;
     request.ObjectId = id;
     return request;
 }
コード例 #6
0
 protected override void ProcessRecord()
 {
     var addableUser = new UpdatableUserObject()
     {
         UserName = UserName,
         FamilyName = FamilyName,
         GivenName = GivenName,
         EMail = EMail,
         Language = Language,
         Role = Role,
         MaxSpace = MaxSpace
     };
     try
     {
         var request = UserRequestFactory.CreateAddUserRequest(addableUser);
         if (ShouldProcess("Add user"))
         {
             WriteObject(RequestHandler.ExecuteAndUnpack<UserObject>(request));
         }
     }
     catch (ReportableException e)
     {
         WriteError(e.ErrorRecord);
     }
 }