Created
April 11, 2024 19:08
-
-
Save hishaamn/23a14fd34d1a2daaccc8620bf9b081ce to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[HttpPost] | |
public IHttpActionResult SendExternalFormEmail(EmailData data) | |
{ | |
IMessageBus<AutomatedMessagesBus> automatedMessageBus = ServiceLocator.ServiceProvider.GetService<IMessageBus<AutomatedMessagesBus>>(); | |
var contact = new ContactIdentifier(data.Source, data.ContactIdentifier, ContactIdentifierType.Known); | |
var dictionary = new Dictionary<string, object>(); | |
foreach (var formData in data.FormData) | |
{ | |
dictionary.Add(formData.Key, formData.Value); | |
} | |
var automatedMessage = new AutomatedMessage() | |
{ | |
ContactIdentifier = contact, | |
MessageId = new Guid(data.EmailCampaignId), | |
CustomTokens = dictionary, | |
TargetLanguage = Sitecore.Context.Language.Name | |
}; | |
automatedMessageBus.Send(automatedMessage); | |
var status = new Status | |
{ | |
StatusCode = "Status 200" | |
}; | |
var apiResponse = new ApiResponse<Status> | |
{ | |
Result = status, | |
StatusCode = "Api Status 200" | |
}; | |
return Json(new { status = HttpStatusCode.OK, response = apiResponse }); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment