diff --git a/Logic/Communications/OutboundComm.cs b/Logic/Communications/OutboundComm.cs index 2a4fc032..88344e5f 100644 --- a/Logic/Communications/OutboundComm.cs +++ b/Logic/Communications/OutboundComm.cs @@ -112,7 +112,7 @@ namespace Swarmops.Logic.Communications } - public static OutboundComm CreateMembershipLetter (ParticipantMailType mailType, Participation participation, + public static OutboundComm CreateParticipantMail (ParticipantMailType mailType, Participation participation, Person actingPerson) { List recipients = People.FromSingle (participation.Person); @@ -134,6 +134,28 @@ namespace Swarmops.Logic.Communications } + public static OutboundComm CreateParticipantMail (string customSubject, string customBody, Participation participation, + Person actingPerson) + { + List recipients = People.FromSingle(participation.Person); + + OutboundComm comm = OutboundComm.Create(null, null, participation.Organization, + CommResolverClass.Unknown, null, + CommTransmitterClass.CommsTransmitterMail, + new PayloadEnvelope(new ParticipantMailPayload(customSubject, customBody, participation, actingPerson)).ToXml(), + OutboundCommPriority.Low); + + foreach (Person person in recipients) + { + comm.AddRecipient(person); + } + + comm.Resolved = true; + + return comm; + } + + public static OutboundComm CreateNotification (Organization organization, string notificationResourceString) { List recipients = People.FromSingle (Person.FromIdentity (1)); // Initial Admin recipient diff --git a/Logic/Communications/Transmission/ParticipantMailPayload.cs b/Logic/Communications/Transmission/ParticipantMailPayload.cs index b91aaf54..32c907f1 100644 --- a/Logic/Communications/Transmission/ParticipantMailPayload.cs +++ b/Logic/Communications/Transmission/ParticipantMailPayload.cs @@ -24,14 +24,13 @@ namespace Swarmops.Logic.Communications.Transmission public string SubjectTemplate { get; set; } public string BodyTemplate { get; set; } - public ParticipantMailPayload (ParticipantMailType mailType, Participation participation, Person actingPerson) { Strings = new SerializableDictionary(); switch (mailType) { - case ParticipantMailType.MemberAddedWelcome: + case ParticipantMailType.ParticipantAddedWelcome: Strings[MailPayloadString.ActingPerson] = actingPerson.Name; Strings[MailPayloadString.MembershipExpiry] = participation.Expires.ToLongDateString(); Strings[MailPayloadString.OrganizationName] = participation.Organization.Name; @@ -52,6 +51,19 @@ namespace Swarmops.Logic.Communications.Transmission } } + + public ParticipantMailPayload (string customSubject, string customBody, Participation participation, + Person actingPerson) + { + Strings = new SerializableDictionary(); + + SubjectTemplate = customSubject; + BodyTemplate = customBody; + Strings[MailPayloadString.ActingPerson] = actingPerson.Name; + Strings[MailPayloadString.OrganizationName] = participation.Organization.Name; + } + + public RenderedComm RenderComm (Person person) { string body = BodyTemplate; @@ -105,7 +117,7 @@ namespace Swarmops.Logic.Communications.Transmission public enum ParticipantMailType { Unknown = 0, - MemberAddedWelcome + ParticipantAddedWelcome } [Serializable] diff --git a/Site5/Pages/v5/Swarm/AddPerson.aspx.cs b/Site5/Pages/v5/Swarm/AddPerson.aspx.cs index b6119466..fc1c0bec 100644 --- a/Site5/Pages/v5/Swarm/AddPerson.aspx.cs +++ b/Site5/Pages/v5/Swarm/AddPerson.aspx.cs @@ -116,7 +116,7 @@ namespace Swarmops.Frontend.Pages.v5.Swarm Participation newParticipation = Participation.Create (newPerson, CurrentOrganization, DateTime.Today.AddYears (1)); - OutboundComm.CreateMembershipLetter (ParticipantMailType.MemberAddedWelcome, newParticipation, CurrentUser); + OutboundComm.CreateParticipantMail (ParticipantMailType.ParticipantAddedWelcome, newParticipation, CurrentUser); SwarmopsLogEntry logEntry = SwarmopsLog.CreateEntry (newPerson, new Swarmops.Logic.Support.LogEntries.PersonAddedLogEntry (newParticipation, CurrentUser));