예제 #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);
     }
 }