public async Task <IActionResult> OnPost(string?transcriptId, List <SampleDto> samples) { var connectionString = Environment.GetEnvironmentVariable("MONGO_CONNECT_STR"); var database = CosmosUtils.ConnectToDatabase(connectionString, "Samples"); var collection = database.GetCollection <SamplesCollection>("Samples"); SamplesCollection samplesCollection = null; foreach (var samplesEntity in await CosmosUtils.GetAllAsync(collection)) { if (samplesEntity.transcriptId == transcriptId) { samplesCollection = samplesEntity; break; } } foreach (var classifiedSample in samples) { foreach (var sample in samplesCollection.samples .Where(s => s.speakerId == classifiedSample.SpeakerId)) { sample.speakerName = classifiedSample.SpeakerName; } } await CosmosUtils.UpdateDocumentAsync(collection, samplesCollection); return(RedirectToPage("../Speakers/Index")); }
public PegExplorer() { samples = new SamplesCollection(); InitializeComponent(); cboGrammar.DisplayMember = "grammarName"; cboGrammar.DataSource = samples.sampleGrammars; LoadSourceFile(""); }
private void OnDataContextChanged(object sender, DependencyPropertyChangedEventArgs e) { if (e.NewValue != null) { SamplesCollection collection = (SamplesCollection)e.NewValue; var query = from r in collection.Releases from d in r.Demonstrations select new DemonstrationViewModel { Demonstration = d, Version = r.Version }; FlatViewModel viewModel = new FlatViewModel(query.ToList()); itemsControl.DataContext = viewModel.Demonstrations; } }
public static async Task DeleteAsync(IMongoCollection <SamplesCollection> collection, SamplesCollection document) { await collection.DeleteOneAsync(x => x.transcriptId == document.transcriptId); }
public static async Task UpdateDocumentAsync(IMongoCollection <SamplesCollection> collection, SamplesCollection document) { await collection.ReplaceOneAsync(x => x.transcriptId == document.transcriptId, document); }
public static async Task AddDocumentAsync(IMongoCollection <SamplesCollection> collection, SamplesCollection document) { await collection.InsertOneAsync(document); }