Example #1
0
        /// <summary>
        /// Unsubscribe from a quiz
        /// </summary>
        /// <param name="dbId">ID to unsub from</param>
        /// <returns>If the unsub was successful</returns>
        public static async Task <OperationReturnMessage> UnsubscribeFromQuizAsync(string dbId)
        {
            QuizInfo info = QuizRosterDatabase.GetQuizInfo(dbId);

            if (info.SyncStatus != (int)SyncStatusEnum.NotDownloadedAndNeedDownload)
            {
                string location = App.UserPath + "/" + info.Category + "/" + info.QuizName + "`" + info.AuthorName;
                if (Directory.Exists(location))
                {
                    Directory.Delete(location, true);
                }
            }

            OperationReturnMessage returnMessage = await Task.Run(async() => await ServerOperations.UnsubscribeToQuizAsync(dbId));

            if (returnMessage == OperationReturnMessage.True)
            {
                QuizRosterDatabase.DeleteQuizInfo(dbId);
                return(returnMessage);
            }
            else if (returnMessage == OperationReturnMessage.FalseInvalidCredentials)
            {
                CredentialManager.IsLoggedIn = false;
                return(returnMessage);
            }
            else
            {
                return(returnMessage);
            }
        }