async void OnCreateProdClicked(object sender, EventArgs e) { Notes = string.Empty; ProductTable _table = new ProductTable(); //this is special case or when necessary to Drop Table (expdate is iverdue or language changed) if (ProductTable != null && !(ProductTable.Equals(string.Empty))) { try { int action = await App.LocalDatabase.DeleteProductTableAsync(_table); ProductTable = null; } catch (Exception ex) { Notes = ex.Message.ToString() + " table not droped....."; } } //await DisplayAlert("Sql Admin", SettingTable, "ok"); if (ProductTable == null || ProductTable.Equals(string.Empty)) { //1,. Create Table App.LocalDatabase.CreateProductTableAsync(); Notes += "table created....."; //inser records, populate from API call (for this excercise use mock file) List <BelProduct> results = GetMocJsonFile("BelzonaMobile.Data.app-manifest-products-us.json"); int cntr = 0; foreach (var item in results) { _table = new ProductTable(); _table.ID = 0; _table.ProductName = item.ProductName; _table.Code = String.Format("{0}.{1}.{2}", item.SeriesId.ToString(), item.Formulation.Trim(), item.TypeId.ToString()); _table.ShortDesc = Regex.Replace(item.ShortDesc, @"<(.|\n)*?>", string.Empty); _table.LongDesc = item.LongDesc; _table.Favourite = 0; _table.ProductImage = "belzonalogo_en_full.png"; try { int inserted = await App.LocalDatabase.SaveProductTableAsync(_table); cntr++; } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("Error:{0}", ex.Message.ToString()); } //for each record insert into ProductTable } Notes += cntr.ToString() + " inserted"; } else { List <ProductTable> results = await App.LocalDatabase.GetProductTableAsync(); //if (results != null) { _table.CurrentLingo = results.CurrentLingo; _table.ExpDate = results.ExpDate; } Notes = "Table Exisit ...." + results.Count.ToString(); } await DisplayAlert(ProductTable, Notes, "ok"); }