static void Main(string[] args) { var notification = new NewBlogPostNotification { BlogName = "MustacheTemplates", EmailAddresses = new List <string> { "*****@*****.**", "*****@*****.**" } }; var client = new BlogPostNotificationsApi("https://localhost:44363"); var result = client.GenerateWithHttpInfo(notification); Console.Write(JsonConvert.SerializeObject(result, Formatting.Indented)); Console.ReadKey(); }
public async Task <IActionResult> Generate([FromBody] NewBlogPostNotification blogPostNotification, CancellationToken cancellationToken) { List <BlogPostNotification> result = new List <BlogPostNotification>(); //Reads the Mustache template and the data to render string template = await GetTemplateAsync(); object view = await GetTemplateDataAsync(blogPostNotification.BlogName); //Creates the message using Stubble string message = StaticStubbleRenderer.Render(template, view); //Adds the results result.AddRange(blogPostNotification.EmailAddresses .Select(x => new BlogPostNotification { EmailAddress = x, Text = message })); return(Ok(result)); }