//This method now saves the notes properly in SQL DB hosted in Azure. public void AddNote(Note note) { if (!lstNotes.Contains(note)) { lstNotes.Add(note); AzureDBService.Write(note); } }
public void DeleteNote(Note note) { if (lstNotes.Contains(note)) { lstNotes.Remove(note); AzureDBService.Delete(note); } }
public static async Task WalkCosmosAccounts(IAzure azure, IAsyncCollector <string> items, ILogger log) { var dBService = new AzureDBService(); var tableTracker = await dBService.GetCosmosAccountInfo(); try { foreach (var cosmosDBAccount in azure.CosmosDBAccounts.List()) { var databaseAccountListKeysResult = cosmosDBAccount.ListKeys(); string masterKey = databaseAccountListKeysResult.PrimaryMasterKey; string endPoint = cosmosDBAccount.DocumentEndpoint; var client = new DocumentClient(new Uri(endPoint), masterKey, ConnectionPolicy.Default); var databases = await client.ReadDatabaseFeedAsync(); log.LogInformation($"Reading all databases resources for - {cosmosDBAccount.Name}"); foreach (var db in databases) { List <DocumentCollection> collections = client.CreateDocumentCollectionQuery((String)db.SelfLink).ToList(); foreach (var col in collections) { var record = tableTracker .Where(x => x.AccountName == cosmosDBAccount.Name) .Where(x => x.DatabaseName == db.Id) .Where(x => x.CollectionName == col.Id).SingleOrDefault(); if (tableTracker == null || record == null) { await dBService.AddNewCollectionRecord(new Cosmosdb() { AccountName = cosmosDBAccount.Name, DatabaseName = db.Id, CollectionName = col.Id }); await items.AddAsync($"{cosmosDBAccount.Name}/{db.Id}/{col.Id}"); } else { await dBService.UpdateCollectionRecord(record.RowKey, record); } } } } } catch (Exception e) { log.LogInformation(e.Message); log.LogInformation(e.StackTrace); } }
public void UpdateNote(Note note) { AzureDBService.Update(note); }
public async Task <List <Note> > GetNotes() { lstNotes = await AzureDBService.GetList(); return(lstNotes); }