Exemplo n.º 1
0
        public void Send_invoice_to_minimail_as_attachment()
        {
            var invoice = CreateInvoice();

            mailer.SendInvoiceToMinimail(invoice);
            mailer.Send();

            Assert.That(message.Body, Is.StringContaining("Примите счет за информационное обслуживание в ИС АналитФармация."));
            Assert.That(message.Attachments.Count, Is.EqualTo(1));
            Assert.That(message.Attachments[0].Name, Is.EqualTo("Счет.html"));
        }
        protected override void Process()
        {
            var invoices = Session.Query <Invoice>()
                           .Where(i => ((i.SendToEmail && i.Payer.InvoiceSettings.EmailInvoice) || (i.SendToMinimail && i.Payer.InvoiceSettings.SendToMinimail)) && i.Date <= DateTime.Today);

            foreach (var invoice in invoices)
            {
                _mailer.Clear();
                if (invoice.SendToEmail && invoice.Payer.InvoiceSettings.EmailInvoice)
                {
                    _mailer.InvoiceToEmail(invoice, false);
                }
                else if (invoice.SendToMinimail && invoice.Payer.InvoiceSettings.SendToMinimail)
                {
                    _mailer.SendInvoiceToMinimail(invoice);
                    invoice.SendToMinimail = false;
                }
                _mailer.Send();

                Session.Save(invoice);
            }
        }