public async Task <string> AddTextNoteAsync(string text, string userId, string categoryId) { if (text.ToLower().Contains("protiviti")) { text = $"{text} - Face the Future with Fear!"; } // create the document in Cosmos DB var textDocument = new TextDocument { UserId = userId, Text = text, CategoryId = categoryId }; var textId = await TextRepository.AddTextNoteAsync(textDocument); // post a TextCreated event to Event Grid var eventData = new TextCreatedEventData { Preview = text.Truncate(MaximumTextPreviewLength), Category = categoryId }; var subject = $"{userId}/{textId}"; await EventGridPublisher.PostEventGridEventAsync(EventTypes.Text.TextCreated, subject, eventData); return(textId); }
public async Task DeleteAudioNoteAsync(string id, string userId) { // delete the blog await blobRepository.DeleteBlobAsync(AudioBlobContainerName, userId, id); // fire an event into the Event Grid topic var subject = $"{userId}/{id}"; await eventGridPublisherService.PostEventGridEventAsync(EventTypes.Audio.AudioDeleted, subject, new AudioDeletedEventData()); }
public async Task <string> AddCategoryAsync(string name, string userId) { // create the document in Cosmos DB var categoryDocument = new CategoryDocument { Name = name, UserId = userId }; var categoryId = await CategoriesRepository.AddCategoryAsync(categoryDocument); // post a CategoryCreated event to Event Grid var eventData = new CategoryCreatedEventData { Name = name }; var subject = $"{userId}/{categoryId}"; await EventGridPublisher.PostEventGridEventAsync(EventTypes.Categories.CategoryCreated, subject, eventData); return(categoryId); }