public async Task <CommandResult> PublishTemplate(Template template) { string templateVersion = $"{template.Current.MajorVersion}.{template.Current.MinorVersion}"; string blobName = $"{template.FundingStream.Id}/{template.FundingPeriod.Id}/{templateVersion}.json"; try { byte[] templateFileBytes = Encoding.UTF8.GetBytes(template.Current.TemplateJson); try { await _fundingTemplateRepositoryPolicy.ExecuteAsync(() => _fundingTemplateRepository.SaveFundingTemplateVersion(blobName, templateFileBytes)); } catch (Exception ex) { throw new NonRetriableException($"Failed to save funding template version: '{blobName}'", ex); } return(await ClearTemplateBlobCache(template, templateVersion)); } catch (Exception ex) { _logger.Error(ex, $"Failed to save funding template '{blobName}' to blob storage"); return(CommandResult.Fail("Error occurred uploading funding template to blob storage: " + ex.Message)); } }
private async Task SaveFundingTemplateVersion(string blobName, byte[] templateBytes) { try { await _fundingTemplateRepositoryPolicy.ExecuteAsync(() => _fundingTemplateRepository.SaveFundingTemplateVersion(blobName, templateBytes)); } catch (Exception ex) { throw new NonRetriableException($"Failed to save funding template version: '{blobName}'", ex); } }