protected override void OnReceive(object message)
        {
            switch (message)
            {
            case CalendarEventAssignedToApprover msg:
                this.GetAdditionalData(msg)
                .ContinueWith(task =>
                {
                    var(ownerEmployeeResult, approverPreferencesResult, approverEmployeeResult) = task.Result;

                    return(new CalendarEventAssignedWithAdditionalData(
                               msg.Event,
                               ownerEmployeeResult.Employees.First().Metadata,
                               approverPreferencesResult.UserPreferences,
                               approverEmployeeResult.Employees.First().Metadata));
                })
                .PipeTo(this.Self);

                break;

            case CalendarEventAssignedWithAdditionalData msg
                when msg.ApproverUserPreferences.EmailNotifications:

                this.logger.Debug("Sending email notification about event {0} of {1} assigned to {2}",
                                  msg.Event.EventId, msg.Owner.EmployeeId, msg.Approver.EmployeeId);

                var datesStr = msg.Event.Dates.StartDate == msg.Event.Dates.EndDate
                        ? msg.Event.Dates.StartDate.ToString("dd/MM/yyyy")
                        : $"{msg.Event.Dates.StartDate:dd/MM/yyyy} - {msg.Event.Dates.EndDate:dd/MM/yyyy}";

                var templateExpressionContext = new Dictionary <string, string>
                {
                    ["eventType"] = msg.Event.Type,
                    ["dates"]     = datesStr,
                    ["employee"]  = msg.Owner.Name
                };

                templateExpressionContext = new DictionaryMerge().Perform(
                    templateExpressionContext,
                    msg.Event.AdditionalData.ToDictionary(x => x.Key, x => x.Value));

                var sender    = this.emailNotificationConfig.NotificationSender;
                var recipient = msg.Approver.Email;
                var subject   = this.emailNotificationConfig.Subject;
                var body      = new TemplateExpressionParser().Parse(this.emailNotificationConfig.Body, templateExpressionContext);

                Context.System.EventStream.Publish(
                    new NotificationEventBusMessage(
                        new EmailNotification(sender, new[] { recipient }, subject, body)));

                break;

            case CalendarEventAssignedWithAdditionalData _:
                break;

            default:
                this.Unhandled(message);
                break;
            }
        }
        private void SendNotification(CalendarEventChangedWithAdditionalData message, IEmailWithFixedRecipientNotification notificationConfiguration)
        {
            var templateExpressionContext = new Dictionary <string, string>
            {
                ["employee"]   = message.Employee.Name,
                ["employeeId"] = message.Employee.EmployeeId,
                ["startDate"]  = message.Event.Dates.StartDate.ToString("dd/MM/yyyy"),
                ["endDate"]    = message.Event.Dates.EndDate.ToString("dd/MM/yyyy")
            };

            templateExpressionContext = new DictionaryMerge().Perform(
                templateExpressionContext,
                message.Event.AdditionalData.ToDictionary(x => x.Key, x => x.Value));

            var templateExpressionParser = new TemplateExpressionParser();

            var sender    = notificationConfiguration.NotificationSender;
            var recipient = notificationConfiguration.NotificationRecipient;
            var subject   = templateExpressionParser.Parse(notificationConfiguration.Subject, templateExpressionContext);
            var body      = templateExpressionParser.Parse(notificationConfiguration.Body, templateExpressionContext);

            Context.System.EventStream.Publish(
                new NotificationEventBusMessage(
                    new EmailNotification(sender, new[] { recipient }, subject, body)));
        }