Esempio n. 1
0
        private void SendNotificationEmail(Dictionary <string, List <AdjusmentEbtViewModel> > injuredPerson)
        {
            MessageTemplate templateEBT = MessageTemplateService.GetMessageTemplate("AjustesEBT.Documentar.EmailTemplate");

            if (templateEBT.IsNull())
            {
                Logger.Error("No se ha configurado la Plantilla de E-Mail para Solicitudes EBT");
                return;
            }


            foreach (var item in injuredPerson)
            {
                var paymentListToBeNotified = new AdjusmentEbtNotificationEmail();
                paymentListToBeNotified.Lesionado       = item.Key;
                paymentListToBeNotified.NumeroCaso      = item.Value[0].CaseNumber;
                paymentListToBeNotified.NumeroCuentaEbt = item.Value[0].EbtNumber;
                paymentListToBeNotified.PaymentTable    = item.Value;

                try
                {
                    var setting_ebt_mail_from = SettingService.GetSettingValueByName("AjustesEBT.Notificaciones.Email.To");
                    var setting_ebt_mail_to   = SettingService.GetSettingValueByName("AjustesEBT.Notificaciones.Email.From");
                    var ebt_mail_from         = new MailAddress(!string.IsNullOrEmpty(setting_ebt_mail_from) ? setting_ebt_mail_from : "*****@*****.**");
                    var ebt_mail_to           = new List <MailAddress>();
                    var ebt_mail_body         = CreateBodyForEmail(paymentListToBeNotified, templateEBT);

                    ebt_mail_to.Add(new MailAddress(!string.IsNullOrEmpty(setting_ebt_mail_to) ? setting_ebt_mail_to : "*****@*****.**"));

                    templateEBT.Subject = templateEBT.Subject.Replace("@tipoajuste", item.Value[0].AdjustmentType);  //por Debito o Credito y @concepto
                    templateEBT.Subject = templateEBT.Subject.Replace("@concepto", item.Value[0].Concept);
                    EmailSenderService.SendEmail(templateEBT.Subject, ebt_mail_body, ebt_mail_from, ebt_mail_to, null, null, null, null);
                }
                catch (Exception ex)
                {
                    Logger.Error("No se ha configurado  E-Mail para Solicitudes EBT", ex);
                }
            }
        }