protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); _data = db.Load().practicesList; SetContentView(Resource.Layout.PracticesActivity); BottomNavigationView navigation = FindViewById <BottomNavigationView>(Resource.Id.PracticesnavigationBar); mRecyclerView = FindViewById <RecyclerView>(Resource.Id.PracticesrecyclerView); mRecyclerView.SetLayoutManager(new LinearLayoutManager(this)); navigation.SetOnNavigationItemSelectedListener(this); mRecyclerView.SetAdapter(new ContentItemAdapter(_data.InScope.ToArray())); }
public async Task <string> InsertdynamoAsync(practices profile) { // First, set up a DynamoDB client for DynamoDB Local // AmazonDynamoDBConfig ddbConfig = new AmazonDynamoDBConfig(); //AmazonDynamoDBClient client; // ddbConfig.ServiceURL = "http://localhost:8000"; // Get a Table object for the table that you created in Step 1 Table table = GetTableObject(dynamoTableName); if (table == null) { return(""); } // Create a Document representing the movie item to be written to the table Document document = new Document(); document["PracticeID"] = profile.PracticeId.ToString(); document["ZipCode"] = profile.ZipCode.Trim(); document["Lat"] = profile.Lat; document["Lon"] = profile.Lon; document["Title"] = profile.Title; document["Info"] = profile.Info; document["Name"] = profile.Name; document["Address"] = profile.Address; document["ContactNumbers"] = profile.ContactNumbers; document["Hours"] = profile.Hours; document["Services"] = profile.Services; document["Promotion"] = profile.Promotion; document["BrandId"] = profile.BrandId; document["Provider1"] = profile.Provider1; document["Provider2"] = profile.Provider2; // document["UpdatedAt"] = profile.UpdatedAt; document["CreatedAt"] = profile.CreatedAt; try { await table.PutItemAsync(document); Console.WriteLine("PutItem succeeded."); } catch (Exception ex) { Console.WriteLine("Error: Table.PutItem failed because:" + ex.Message); } return(null); }
public async Task <string> MssqlAsync(string query) { SqlConnection conn = new SqlConnection(connectionString); SqlDataReader rdr = null; string json = ""; if (query == "insertSql") { try { // 2. Open the connection conn.Open(); // 3. Pass the connection to a command object SqlCommand cmd = new SqlCommand(command, conn); // // 4. Use the connection // // get query results rdr = cmd.ExecuteReader(); practices profile = new practices(); // print the CustomerID of each record while (rdr.Read()) { profile.PracticeId = (long)rdr["PracticeId"]; profile.ZipCode = rdr["ZipCode"].ToString().Trim(); profile.Lat = (decimal)rdr["Lat"]; profile.Lon = (decimal)rdr["Lon"]; profile.Title = (string)rdr["Title"]; profile.Info = (string)rdr["Info"]; profile.Name = (string)rdr["Name"]; profile.Address = (string)rdr["Address"]; profile.ContactNumbers = (string)rdr["ContactNumbers"]; profile.Hours = (string)rdr["Hours"]; profile.Services = (string)rdr["Services"]; profile.Promotion = (string)rdr["Promotion"]; profile.BrandId = (string)rdr["BrandId"]; profile.Provider1 = (string)rdr["Provider1"]; profile.Provider2 = (string)rdr["Provider2"]; json = json + JsonConvert.SerializeObject(profile) + "\n"; await InsertdynamoAsync(profile); } } finally { // 5. Close the connection if (conn != null) { conn.Close(); } } } else { json = "else"; } return(json); }