示例#1
0
        /// <summary>
        /// Moves the account to the smartschool class. This is a static function because it can also be
        /// called from other actions, like adding the account
        /// </summary>
        /// <param name="linkedAccount"></param>
        /// <returns></returns>
        public static async Task Move(State.Linked.LinkedAccount linkedAccount, AccountApi.IGroup group)
        {
            if (group != null)
            {
                bool result = await AccountApi.Smartschool.GroupManager.MoveUserToClass(linkedAccount.Smartschool.Account, group, linkedAccount.Wisa.Account.ClassChange).ConfigureAwait(false);

                if (result)
                {
                    MainWindow.Instance.Log.AddMessage(AccountApi.Origin.Smartschool, linkedAccount.Wisa.Account.FullName + " moved to " + linkedAccount.Wisa.Account.ClassName);
                }
                else
                {
                    MainWindow.Instance.Log.AddError(AccountApi.Origin.Smartschool, "Failed to move " + linkedAccount.Wisa.Account.FullName + " to " + linkedAccount.Wisa.Account.ClassName);
                }
            }
            else
            {
                MainWindow.Instance.Log.AddError(AccountApi.Origin.Smartschool, "Class " + linkedAccount.Wisa.Account.ClassName + " does not exist.");
            }
        }
        private void AddSmartschoolAccounts(AccountApi.IGroup group)
        {
            foreach (var account in group.Accounts)
            {
                if (List.ContainsKey(account.UID))
                {
                    List[account.UID].Smartschool.Account = account as AccountApi.Smartschool.Account;
                }
                else
                {
                    List.Add(account.UID, new LinkedAccount(account as AccountApi.Smartschool.Account));
                }
            }

            if (group.Children != null)
            {
                foreach (var child in group.Children)
                {
                    AddSmartschoolAccounts(child);
                }
            }
        }