using System.Text; using PdfService.Models; namespace PdfService.Utility { public static class TemplateGenerator { public static string GetHTMLString(Term[] terms) { var sb = new StringBuilder(); sb.Append(@" <html> <head> </head> <body> <section class='hero is-info'> <div class='hero-body' style='padding-left:3em'> <div class='container'> <h1 class='title'> Tweet Sentiment Analysis </h1> <h2 class='subtitle'> Results for the terms </h2> </div> </div> </section> <div class='container' style='margin-left:3em; margin-right:3em'> "); foreach (Term term in terms) { string color = ""; if(term.Sentiment < 0.33) color = "is-danger"; else if(term.Sentiment < 0.66) color = "is-warning"; else color = "is-success"; sb.AppendFormat(@"<div class='container' style='margin-top:3em;'> <p class='title is-5'>{0}</p> <div class='content'> Sentiment Analysis Result: <div class='column'><progress class='progress {2}' value='{1}' max='100'>{1}%</progress></div> </div> </div>", term.Name, System.Math.Ceiling(term.Sentiment*100), color); } sb.Append(@" </div> </body> </html>"); return sb.ToString(); } } }