public static ObjectRequest CreateAddUserRequest(UpdatableUserObject data) { var request = CreateUserObjectRequest("Add User", Method.POST); var updates = BuildJsonUpdateDict(data); request.Data = updates; return request; }
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) ); }
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) ); }
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; }
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; }
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); } }