internal static void ChangePasswordAsync(string oldPassword, string newPassword, ChangePasswordCallback callback)
        {
            Guid callerKey = Guid.NewGuid();
            ApartmentServiceClient proxy = GetProxy(callerKey, callback);

            proxy.ChangePasswordCompleted += new EventHandler <ChangePasswordCompletedEventArgs>(proxy_ChangePasswordCompleted);
            proxy.ChangePasswordAsync(oldPassword, newPassword, callerKey);
        }
        internal static void GetAspUserAsync(Guid userId, GetAspUserCallBack callback)
        {
            Guid callerKey = Guid.NewGuid();
            ApartmentServiceClient proxy = GetProxy(callerKey, callback);

            proxy.GetAspUserCompleted += new EventHandler <GetAspUserCompletedEventArgs>(proxy_GetAspUserCompleted);
            proxy.GetAspUserAsync(userId, callerKey);
        }
        internal static void GetGlobalVariableAsync(GetGlobalVariableCallBack callback)
        {
            Guid callerKey = Guid.NewGuid();
            ApartmentServiceClient proxy = GetProxy(callerKey, callback);

            proxy.GetGlobalVariableCompleted += new EventHandler <GetGlobalVariableCompletedEventArgs>(proxy_GetGlobalVariableCompleted);
            proxy.GetGlobalVariableAsync(callerKey);
        }
        internal static void SaveAspUserAsync(common.AspUser saveUser, SaveAspUserCallBack callback)
        {
            Guid callerKey = Guid.NewGuid();
            ApartmentServiceClient proxy = GetProxy(callerKey, callback);

            proxy.SaveAspUserCompleted += new EventHandler <SaveAspUserCompletedEventArgs>(proxy_SaveAspUserCompleted);
            proxy.SaveAspUserAsync(saveUser, callerKey);
        }
        internal static void UnlockAspUserAsync(common.AspUser oldUser, UnlockAspUserCallBack callback)
        {
            Guid callerKey = Guid.NewGuid();

            ApartmentServiceClient proxy = GetProxy(callerKey, callback);

            proxy.UnlockAspUserCompleted += new EventHandler <UnlockAspUserCompletedEventArgs>(proxy_UnlockAspUserCompleted);
            proxy.UnlockAspUserAsync(oldUser, callerKey);
        }
        internal static void ListOrgAdminAspUserAsync(int orgId, Guid roleid, ListOrgAdminAspUserCallBack callback)
        {
            Guid callerKey = Guid.NewGuid();

            ApartmentServiceClient proxy = GetProxy(callerKey, callback);

            proxy.ListOrgAdminAspUserCompleted += new EventHandler <ListOrgAdminAspUserCompletedEventArgs>(proxy_ListOrgAdminAspUserCompleted);
            proxy.ListOrgAdminAspUserAsync(orgId, roleid, callerKey);
        }
        internal static void ListAspUserAsync(int?orgId, Guid?userId, bool?isLegacy, bool loadCentreId, ListAspUserCallBack callback)
        {
            Guid callerKey = Guid.NewGuid();

            ApartmentServiceClient proxy = GetProxy(callerKey, callback);

            proxy.ListAspUserCompleted += new EventHandler <ListAspUserCompletedEventArgs>(proxy_ListAspUserCompleted);
            proxy.ListAspUserAsync(orgId, userId, isLegacy, callerKey);
        }
        private static ApartmentServiceClient GetProxy(Guid callerKey, Delegate callback)
        {
            ApartmentServiceClient result = new ApartmentServiceClient();
            // Rely on the endpoint addresses being setup within ServiceReferences.ClientConfig instead.
            // result.Endpoint.Address = new EndpointAddress(Globals.EndPointAddresses.DataService);            
            if (callback != null)
            {
                _callbacks.Add(callerKey, callback);
            }

            return result;
        }
        private static ApartmentServiceClient GetProxy(Guid callerKey, Delegate callback)
        {
            ApartmentServiceClient result = new ApartmentServiceClient();

            // Rely on the endpoint addresses being setup within ServiceReferences.ClientConfig instead.
            // result.Endpoint.Address = new EndpointAddress(Globals.EndPointAddresses.DataService);
            if (callback != null)
            {
                _callbacks.Add(callerKey, callback);
            }

            return(result);
        }