Ejemplo n.º 1
0
        public FileMetadata SendDefaultNoticeComm14Borrower(CollectionMailModel model)
        {
            var variables = new Dictionary <string, string> {
                { "CustomerName", model.CustomerName },
                { "CompanyName", model.CompanyName },
                { "GuarantorName", model.GuarantorName },
                { "Date", model.Date.ToLongDateWithDayOfWeek() },
                { "LoanRef", model.LoanRef },
                { "LoanDate", model.LoanDate.ToLongDate() },
                { "LoanAmount", model.LoanAmount.ToNumericNoDecimals() },
                { "SchedDate", model.MissedPayment.DateDue.ToLongDate() },
                { "AmountDue", model.MissedPayment.AmountDue.ToNumeric2Decimals() },
                { "AmountPaid", model.MissedPayment.RepaidAmount.ToNumeric2Decimals() },
                { "AmountTotal", (model.MissedPayment.AmountDue - model.MissedPayment.RepaidAmount).ToNumeric2Decimals() },
                { "OutstandingBalance", model.OutstandingBalance.ToNumeric2Decimals() },
            };

            SetAddress(model.CustomerAddress, ref variables);

            var templateModel = this.templates.FirstOrDefault(x => x.TemplateName == DefaultnoticeComm14BorrowerTemplateName && model.OriginId == x.OriginID && x.IsActive);

            if (templateModel == null)
            {
                Log.Warn("template " + DefaultnoticeComm14BorrowerTemplateName + " was not found for origin" + model.OriginId);
                return(null);
            }
            Stream template = PrepareMail.ByteArrayToStream(templateModel.Template);

            byte[] pdfData = PrepareMail.ReplaceParametersAndConvertToPdf(template, variables);
            return(SendMail(pdfData, model.CustomerId, DefaultnoticeComm14BorrowerTemplateName, templateModel.ID));
        }
Ejemplo n.º 2
0
        public FileMetadata SendDefaultTemplateConsumer31(CollectionMailModel model)
        {
            var variables = new Dictionary <string, string> {
                { "CustomerName", model.CustomerName },
                { "Date", model.Date.ToLongDateWithDayOfWeek() },
                { "LoanRef", model.LoanRef },
                { "LoanDate", model.LoanDate.ToLongDate() },
                { "TotalBalance", (model.MissedInterest + model.OutstandingPrincipal).ToNumeric2Decimals() },
                { "AmountDue1", (model.PreviousMissedPayment.AmountDue).ToNumeric2Decimals() },
                { "DateDue1", (model.PreviousMissedPayment.DateDue).ToLongDate() },
                { "PartialPaid1", (model.PreviousMissedPayment.RepaidAmount).ToNumeric2Decimals() },
                { "RepaidDate1", (model.PreviousMissedPayment.RepaidDate).ToLongDate() },
                { "Total1", (model.PreviousMissedPayment.AmountDue - model.PreviousMissedPayment.RepaidAmount).ToNumeric2Decimals() },
                { "AmountDue2", (model.MissedPayment.AmountDue).ToNumeric2Decimals() },
                { "DateDue2", (model.MissedPayment.DateDue).ToLongDate() },
                { "PartialPaid2", (model.MissedPayment.RepaidAmount).ToNumeric2Decimals() },
                { "RepaidDate2", (model.MissedPayment.RepaidDate).ToLongDate() },
                { "Total2", (model.MissedPayment.AmountDue - model.MissedPayment.RepaidAmount).ToNumeric2Decimals() },
                { "Total", (model.MissedPayment.AmountDue - model.MissedPayment.RepaidAmount + model.PreviousMissedPayment.AmountDue - model.PreviousMissedPayment.RepaidAmount).ToNumeric2Decimals() },
            };

            SetAddress(model.CustomerAddress, ref variables);

            var templateModel = this.templates.FirstOrDefault(x => x.TemplateName == DefaulttemplateConsumer31TemplateName && model.OriginId == x.OriginID && x.IsActive);

            if (templateModel == null)
            {
                Log.Warn("template " + DefaulttemplateConsumer31TemplateName + " was not found for origin" + model.OriginId);
                return(null);
            }

            Stream template = PrepareMail.ByteArrayToStream(templateModel.Template);

            byte[] pdfData          = PrepareMail.ReplaceParametersAndConvertToPdf(template, variables);
            byte[] concatinatedMail = pdfData;

            var attachmentTemplateModel = this.templates.FirstOrDefault(x => x.TemplateName == DefaulttemplateConsumer31Attachment && model.OriginId == x.OriginID && x.IsActive);

            if (attachmentTemplateModel != null)
            {
                concatinatedMail = PrepareMail.ConcatinatePdfFiles(new List <byte[]> {
                    pdfData,
                    attachmentTemplateModel.Template
                });
            }
            else
            {
                Log.Warn("template " + DefaulttemplateConsumer31Attachment + " was not found for origin" + model.OriginId);
            }

            return(SendMail(concatinatedMail, model.CustomerId, DefaulttemplateConsumer31TemplateName, templateModel.ID));
        }
Ejemplo n.º 3
0
        public void SendDefaultTemplateComm7(CollectionMailModel model, out FileMetadata personalFileMetadata, out FileMetadata businessFileMetadata)
        {
            var variables = new Dictionary <string, string> {
                { "CustomerName", model.CustomerName },
                { "CompanyName", model.CompanyName },
                { "Date", model.Date.ToLongDateWithDayOfWeek() },
                { "LoanRef", model.LoanRef },
                { "LoanDate", model.LoanDate.ToLongDate() },
                { "LoanAmount", model.LoanAmount.ToNumericNoDecimals() },
                { "SchedDate", model.MissedPayment.DateDue.ToLongDate() },
                { "AmountDue", model.MissedPayment.AmountDue.ToNumeric2Decimals() },
                { "AmountPaid", model.MissedPayment.RepaidAmount.ToNumeric2Decimals() },
                { "AmountTotal", (model.MissedPayment.AmountDue - model.MissedPayment.RepaidAmount).ToNumeric2Decimals() },
                { "OutstandingBalance", model.OutstandingBalance.ToNumeric2Decimals() },
            };

            personalFileMetadata = SendDefaultTemplateComm7Personal(model.CustomerId, variables, model.CustomerAddress, model.OriginId);
            businessFileMetadata = SendDefaultTemplateComm7Business(model.CustomerId, variables, model.CompanyAddress, model.OriginId);
        }