public async Task SaveMappingAsync(ActionMapping m) { ActionMappingBlobResults existingResults = await GetActionsAndEtagAsync(); List <ActionMapping> existingMappings = existingResults.ActionMappings; // look for the new mapping ActionMapping found = existingMappings.FirstOrDefault(a => a.RuleOutput.ToLower() == m.RuleOutput.ToLower()); if (found == null) { // add the new mapping existingMappings.Add(m); } else { // update the ActionId for the found mapping found.ActionId = m.ActionId; } // now save back to the blob string newJsonData = JsonConvert.SerializeObject(existingMappings); byte[] newBytes = Encoding.UTF8.GetBytes(newJsonData); await _blobStorageManager.UploadFromByteArrayAsync( _blobName, newBytes, 0, newBytes.Length, AccessCondition.GenerateIfMatchCondition(existingResults.ETag), null, null); }
public async Task <List <ActionMapping> > GetAllMappingsAsync() { ActionMappingBlobResults results = await GetActionsAndEtagAsync(); return(results.ActionMappings); }