/// <summary> /// Handler for the SendNonWinnerEmailCommand /// </summary> /// <param name="command">The SendNonWinnerEmailCommand</param> public void HandleCommand(SendNonWinnerEmailCommand command) { List <string> nonWinners = eventRepository.GetAllNonWinnersForEvent(command.EventId); //Query for the email template EmailTemplate nonWinnerEmail = emailRepository.GetEmailTemplate(new EmailTemplate(Enumeration.TryFindById <EmailTemplateEnum>(3).DisplayValue)); if (nonWinners != null && nonWinners.Any()) { foreach (string email in nonWinners) { nonWinnerEmail.EmailSubject = nonWinnerEmail.EmailSubject.Replace("@@EventName@@", command.EventName); emailRepository.SendEmail(new Email( Me2YouConstants.EmailProfile, email, nonWinnerEmail.EmailSubject, nonWinnerEmail.EmailBody)); } } }
/// <summary> /// Sends an email to each individual who has not won tickets for an event. /// <param name="eventId">the id of the event to send the emails for</param> /// <param name="eventName">the name of the event to send emails for</param> /// </summary> public void SendNonWinnerEmail(int eventId, string eventName) { SendNonWinnerEmailCommand nonWinnerEmailCommand = new SendNonWinnerEmailCommand(eventId, eventName); commandBus.Execute(nonWinnerEmailCommand); }