public static void SaveUserList(UserListViewModel viewModel) { ApplicationData.Users = viewModel.UsersList; //ApplicationData.QuickStatistics.UserQuickStats.Clear(); foreach (DataTypes.User userObject in ApplicationData.Users.Users) { if (!CheckIfUserExistsInList(userObject) && userObject.ID != 0 && userObject.Valid) { ApplicationData.QuickStatistics.UserQuickStats.Add(new UserQuickStat(userObject.Name, userObject.ID)); } } for (int i = ApplicationData.QuickStatistics.UserQuickStats.Count - 1; i >= 0; i--) { if (!CheckIfUserExistsInList(ApplicationData.QuickStatistics.UserQuickStats[i].Name, ApplicationData.Users.Users)) { ApplicationData.QuickStatistics.UserQuickStats.RemoveAt(i); } } }
//Adds a new call to the API queue to get the users list public static void GetHelpScoutUserList(UserListViewModel viewModel) { userListCallbackHandler = new ViewModelUserListCallback(viewModel.RecieveHelpScoutUserList); //Sets teh delegate for the viewmodel callback BaseApiRequest<Paged<HelpScoutNet.Model.User>> apiRequest = new BaseApiRequest<Paged<HelpScoutNet.Model.User>>(APICallType.ListUsers); apiRequest.ResultReady += AcceptHelpScoutUserList; apiRequest.resultsFailedHandler = new BaseAPIRequest.ResultsFailed(viewModel.FailedToRetrieveHelpScoutUsersList); HelpScoutRequestManager.NewQueueItem(apiRequest); }