Beispiel #1
0
        // Get Table Prompts from remote database and creating new one in local database
        public async Task GetTablePrompts()
        {
            try
            {
                // Call REST service to send Json data
                RestService rs = new RestService();

                // Get table Prompts Json data from server
                Task <List <PromptsModel> > jsonRetrievePrompts = rs.RetrieveTablePromptsJson();

                // If there was an error in PostJsonDataAsync class, display message
                if (jsonRetrievePrompts == null)
                {
                    Message = rs.Message;
                    return;
                }

                // Create instance of JsonResponseModel and pass jsonResponeTask there
                var jsonResponse = await jsonRetrievePrompts;

                //Task dropTable = Task.Factory.StartNew(() => database.DropTableAsync<PromptsModel>());

                //dropTable.Wait();

                // Insert list of prompts in database
                //if (dropTable.IsCompleted)
                await database.InsertAllAsync(jsonResponse);

                Console.WriteLine(rs.Message);
            }
            catch (SQLiteException ex)
            {
                Console.WriteLine(ex.Message);
            }
        }