I have the code as shown below, and I want to replace the TemplateService with the newer RazorEngineService. Could you show me how to replace it in my code?
PS: I've checked https://antaris.github.io/RazorEngine/ but I get some exceptions when I try to refactor the code to RazorEngineService.
public class ReminderEmail
{
string templateFolderPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "EmailTemplates");
string templateFilePath;
ReminderEmailModel model;
public ReminderEmail(ReminderEmailModel model)
{
this.model = model;
try
{
templateFilePath = Path.Combine(templateFolderPath, "ReminderEmail.cshtml");
}
catch (FileNotFoundException e)
{
//TODO: log file not found here
}
}
public string GetHtmlBody()
{
var templateService = new TemplateService();
var emailHtmlBody = templateService.Parse(File.ReadAllText(templateFilePath), model, null, null);
return emailHtmlBody;
}
}