#1462 #865 Had to refactor how we use notificaitons. So we now have more notification fields about the request

This commit is contained in:
Jamie.Rees 2017-07-05 13:04:26 +01:00
parent b69b322bd5
commit b52a57b117
21 changed files with 256 additions and 112 deletions

View file

@ -6,22 +6,34 @@ namespace Ombi.Notifications.Templates
{
public class EmailBasicTemplate : IEmailBasicTemplate
{
public string TemplateLocation => Path.Combine(Directory.GetCurrentDirectory(), "Templates","BasicTemplate.html");
public string TemplateLocation
{
get
{
#if DEBUG
return Path.Combine(Directory.GetCurrentDirectory(), "bin","Debug", "netcoreapp1.1","Templates", "BasicTemplate.html");
#else
return Path.Combine(Directory.GetCurrentDirectory(), "Templates","BasicTemplate.html");
#endif
}
}
private const string SubjectKey = "{@SUBJECT}";
private const string BodyKey = "{@BODY}";
private const string ImgSrc = "{@IMGSRC}";
private const string DateKey = "{@DATENOW}";
public string LoadTemplate(string subject, string body, string imgSrc)
public string LoadTemplate(string subject, string body, string img)
{
try
{
var sb = new StringBuilder(File.ReadAllText(TemplateLocation));
sb.Replace(SubjectKey, subject);
sb.Replace(BodyKey, body);
sb.Replace(ImgSrc, imgSrc);
sb.Replace(DateKey, DateTime.Now.ToString("f"));
sb.Replace(ImgSrc, img);
return sb.ToString();
}