Пример #1
0
        private string RenderContent(object model, EmailContentPart contentPart)
        {
            string templatePath = GetTemplatePath(model, contentPart);
            string content      = viewRenderer.RenderView(templatePath, model, settings.BaseUri);

            return(content);
        }
Пример #2
0
        private string GetTemplatePath(object model, EmailContentPart contentPart)
        {
            // By convention, the template for each content element is located in a folder
            // based on the name of the model
            const string modelSuffix = "Model";
            string       folder      = model.GetType().Name;

            if (folder.EndsWith(modelSuffix))
            {
                folder = folder.Substring(0, folder.Length - modelSuffix.Length);
            }
            return(string.Format("~/Views/{0}/{1}.cshtml", folder, contentPart));
        }