Skip to content

Commit

Permalink
Populate should return MvcMailMessage. Cleanup T4 templates.
Browse files Browse the repository at this point in the history
  • Loading branch information
tylermercier committed Oct 1, 2012
1 parent f02c4fd commit e4b1bcb
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Mvc.Mailer/MailerBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public virtual string EmailBody(string viewName, string masterName = null) {
/// Populates the mailMessage with content rendered from the view using the default masterName
/// </summary>
/// <param name="action">Action to be performed on a new message instance</param>
public virtual MailMessage Populate(Action<MvcMailMessage> action) {
public virtual MvcMailMessage Populate(Action<MvcMailMessage> action) {
var message = new MvcMailMessage();

action(message);
Expand Down
Binary file modified Mvc.Mailer/NuGet/input/lib/40/Mvc.Mailer.dll
Binary file not shown.
3 changes: 1 addition & 2 deletions Mvc.Mailer/NuGet/input/tools/cs/MailerMethodTemplate.cs.t4
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@ public virtual MailMessage <#= Model.MethodName #>()
x.ViewName = "<#= Model.MethodName #>";
x.To.Add("some-email@example.com");
});
}

}
23 changes: 7 additions & 16 deletions Mvc.Mailer/NuGet/input/tools/cs/MailerTemplate.cs.t4
Original file line number Diff line number Diff line change
@@ -1,37 +1,28 @@
<#@ Template Language="C#" HostSpecific="True" Inherits="DynamicTransform" #>
<#@ Output Extension="cs" #>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Mvc.Mailer;
using System.Net.Mail;

namespace <#= Model.Namespace #>.Mailers
{
public class <#= Model.MailerName #> : MailerBase<# if( Model.Interface) { #>, I<#= Model.MailerName #> <# } #>

{
public <#= Model.MailerName #>():
base()
public <#= Model.MailerName #>()
{
MasterName="_Layout";
}

<# foreach(var mailerMethod in Model.MailerMethods) {#>

public virtual MailMessage <#= mailerMethod #>()
{
var mailMessage = new MailMessage{Subject = "<#= mailerMethod #>"};

//mailMessage.To.Add("some-email@example.com");
//ViewBag.Data = someObject;
PopulateBody(mailMessage, viewName: "<#= mailerMethod #>");

return mailMessage;
return Populate(x =>
{
x.Subject = "<#= mailerMethod #>";
x.ViewName = "<#= mailerMethod #>";
x.To.Add("some-email@example.com");
});
}

<# } #>

}
}
Binary file modified Mvc.Mailer/NuGet/output/MvcMailer.1.2.nupkg
Binary file not shown.

0 comments on commit e4b1bcb

Please sign in to comment.