示例#1
0
        public static void AddNewsletter(NewsletterViewModel nvm)
        {
            newsletter nl = new newsletter {
                DateCreated = DateTime.Now,
                DateUpdated = DateTime.Now,
                DateSent = null,
                AddPersonalLoginLink = nvm.IncludeLoginLink,
                IntroText = nvm.IntroText,
                Title = nvm.Title,
                AttachmentFilePath = nvm.AttachmentFilePath,
                Audience = (int) nvm.SubscriptionStatus
            };

            if (nvm.Items != null) {
                foreach(NewsletterItemViewModel nivm in nvm.Items) {
                    DB.AddTonewsletteritem(new newsletteritem() {
                        ItemTitle = nivm.Title,
                        ItemSubTitle = nivm.SubTitle,
                        SequenceNumber = nivm.SequenceNumber,
                        ItemText = nivm.Text,
                        PictureURL = nivm.ImagePath,
                        newsletter = nl
                    });
                }
            }

            DB.AddTonewsletter(nl);
            DB.SaveChanges();

            nvm.ID = nl.Id;
        }
示例#2
0
        public ActionResult CreateNewsletter(NewsletterViewModel nvm)
        {
            nvm.DateUpdated = DateTime.Now;

            if (ModelState.IsValid) {
                if (nvm.ID == 0) {
                    NewsletterRepository.AddNewsletter(nvm);
                } else {
                    NewsletterRepository.UpdateNewsletter(nvm);
                }
            }

            return View(nvm);
        }
示例#3
0
        public static NewsletterViewModel GetByID(int id)
        {
            newsletter nl;
            try {
                nl = DB.newsletter.Where(n => n.Id == id).Single();
            } catch (Exception) {
                return null;
            }
            List<newsletteritem> nlis = DB.newsletteritem.Where(nli => nli.NewsletterId == nl.Id).ToList();

            NewsletterViewModel nivm = new NewsletterViewModel {
                ID = nl.Id,
                DateCreated = nl.DateCreated,
                DateUpdated = nl.DateUpdated,
                DateSent = nl.DateSent,
                Title = nl.Title,
                IntroText = nl.IntroText,
                AttachmentFilePath = nl.AttachmentFilePath,
                IncludeLoginLink = nl.AddPersonalLoginLink.HasValue && nl.AddPersonalLoginLink.Value,
                SubscriptionStatus = nl.Audience.HasValue ? (NewsletterSubscriptionStatus) nl.Audience.Value : NewsletterSubscriptionStatus.OnlyToMembers
            };

            nivm.Items = new List<NewsletterItemViewModel>();

            foreach (newsletteritem nli in nlis) {
                nivm.Items.Add(
                    new NewsletterItemViewModel {
                        ID = nli.NewsletterId,
                        SequenceNumber = nli.SequenceNumber,
                        SubTitle = nli.ItemSubTitle,
                        Title = nli.ItemTitle,
                        Text = nli.ItemText,
                        ImagePath = nli.PictureURL,
                        IconImagePath = nli.IconPictureURL,
                        HeadingHtmlColour = nli.HeadingHtmlColour
                    }
                );
            }

            return nivm;
        }
示例#4
0
        public ActionResult CreateNewsletter(string id)
        {
            if (string.IsNullOrEmpty(id)) {
                NewsletterViewModel nvm = new NewsletterViewModel();
                nvm.DateCreated = DateTime.Now;
                nvm.DateSent = null;
                nvm.DateUpdated = null;

                nvm.Items = new List<NewsletterItemViewModel>() {
                    new NewsletterItemViewModel {
                        Title = "Nieuwsbrief item"
                    },
                    new NewsletterItemViewModel {
                        Title = "Nieuwsbrief item"
                    }
                };

                return View(nvm);
            } else {
                int ID = Convert.ToInt32(id);
                return View(NewsletterRepository.GetByID(ID));
            }
        }
示例#5
0
        public static void UpdateNewsletter(NewsletterViewModel nvm)
        {
            newsletter nl = DB.newsletter.Where(n => n.Id == nvm.ID).Single();

            nl.DateUpdated = DateTime.Now;
            nl.DateSent = nvm.DateSent;
            nl.IntroText = nvm.IntroText;
            nl.Title = nvm.Title;
            nl.AttachmentFilePath = nvm.AttachmentFilePath;
            nl.AddPersonalLoginLink = nvm.IncludeLoginLink;
            nl.Audience = (int) nvm.SubscriptionStatus;
            List<newsletteritem> nlis = DB.newsletteritem.Where(nli => nli.NewsletterId == nl.Id).ToList();

            foreach (newsletteritem nli in nlis) {
                DB.newsletteritem.DeleteObject(nli);
            }

            if (nvm.Items != null) {
                foreach (NewsletterItemViewModel nivm in nvm.Items) {
                    DB.AddTonewsletteritem(new newsletteritem() {
                        ItemTitle = nivm.Title,
                        ItemSubTitle = nivm.SubTitle,
                        SequenceNumber = nivm.SequenceNumber,
                        ItemText = nivm.Text,
                        PictureURL = nivm.ImagePath,
                        IconPictureURL = nivm.IconImagePath,
                        HeadingHtmlColour = nivm.HeadingHtmlColour,
                        newsletter = nl
                    });
                }
            }

            DB.SaveChanges();
        }
        /// <summary>
        /// Stuurt een bevestigingsmail van inschrijving naar de gebruiker.
        /// Hiervoor wordt de nieuwsbrief template gebruikt.
        /// </summary>
        /// <param name="model"></param>
        private void SendSubscriptionConfirmationMail(InschrijvingModel model)
        {
            NewsletterViewModel newsletter = new NewsletterViewModel();
            newsletter.IncludeLoginLink = true;
            newsletter.Items = new List<NewsletterItemViewModel>();

            if (!model.DoForceSendConfirmationOfChange) {
                newsletter.IntroText = string.Format("Proficiat! Je hebt je zojuist aangemeld voor Hét Rondje Eilanden! ");
                if (!model.IsBetaald.HasValue || !model.IsBetaald.Value) {
                    newsletter.IntroText += "Je aanmelding wordt omgezet naar een inschrijving na betaling van het inschrijfgeld.";
                } else {
                    newsletter.IntroText += "Je hebt betaald en bent nu ingeschreven.";
                }
            } else {
                if (model.EmailBeforeUpdateIfAny!=model.Email) {
                    newsletter.IntroText = string.Format("Je bent aangemeld voor Hét Rondje Eilanden! Je hebt je e-mail adres gewijzigd, of iemand anders heeft zijn inschrijving naar jouw e-mail overgezet. Bevestig je inschrijving en dit e-mail adres via onderstaande link. ");
                } else {
                    newsletter.IntroText = string.Format("Hier een Flessenpost achtige mail omdat je je inschrijfgegevens hebt gewijzigd.");
                }
            }
            newsletter.IntroText += "<br/>Hieronder ter bevestiging nogmaals je inschrijfgegevens. Als er iets niet klopt graag direct zelf wijzigen door op de website in te loggen via de persoonlijke link hiernaast.";

            NewsletterItemViewModel item1 = new NewsletterItemViewModel();
            if (!model.DoForceSendConfirmationOfChange) {
                item1.Title = "You're in!";
                item1.SubTitle = "voor Hét Rondje Eilanden";
            } else {
                item1.Title = "Thanks for the update!";
                item1.SubTitle = "...change is the only constant :)";
            }
            item1.HeadingHtmlColour = "208900";
            item1.ImagePath = "News_2013.png";
            item1.IconImagePath = "News_TileEB.png";

            item1.Text = string.Format("");
            item1.Text += string.Format("<table>");
                item1.Text += string.Format("<tr><td></td></tr>");
                item1.Text += string.Format("<tr><th colspan=\"2\"><b>Inschrijfgegevens</b></th></tr>");

                item1.Text += string.Format("<tr><td>Naam</td><td>{0}</span></td></tr>", model.VolledigeNaamMetAanhef);
                item1.Text += string.Format("<tr><td>Geboortedatum</td><td>{0}</span></td></tr>", model.GeboorteDatum.HasValue ? model.GeboorteDatum.Value.ToShortDateString() : "-");
                item1.Text += string.Format("<tr><td>NTB Licentie</td><td>{0}</span></td></tr>", string.IsNullOrEmpty(model.LicentieNummer) ? " - " : model.LicentieNummer);
                item1.Text += string.Format("<tr><td>Persoonlijke MyLaps Chip</td><td>{0}</span></td></tr>", string.IsNullOrEmpty(model.MyLapsChipNummer) ? " - " : model.MyLapsChipNummer);

                item1.Text += string.Format("<tr><td></td></tr>");
                item1.Text += string.Format("<tr><th colspan=\"2\"><b>Persoonsgegevens</b></th></tr>");

                item1.Text += string.Format("<tr><td>Geslacht</td><td>{0}</span></td></tr>", model.Geslacht ?? "-");
                item1.Text += string.Format("<tr><td>Straat</td><td>{0}</span></td></tr>", model.Straat ?? "-");
                item1.Text += string.Format("<tr><td>Huisnummer</td><td>{0}</span></td></tr>", model.Huisnummer ?? "-");
                item1.Text += string.Format("<tr><td>Toevoeging</td><td>{0}</span></td></tr>", model.HuisnummerToevoeging ?? "-");
                item1.Text += string.Format("<tr><td>Postcode</td><td>{0}</span></td></tr>", model.Postcode ?? "-");
                item1.Text += string.Format("<tr><td>Woonplaats</td><td>{0}</span></td></tr>", model.Woonplaats?? "-");
                item1.Text += string.Format("<tr><td>Land</td><td>{0}</span></td></tr>", model.Land ?? "-");
                item1.Text += string.Format("<tr><td>E-mail adres</td><td>{0}</span></td></tr>", model.Email ?? "-");
                item1.Text += string.Format("<tr><td>Telefoon</td><td>{0}</span></td></tr>", model.Telefoon ?? "-");

                item1.Text += string.Format("<tr><td></td></tr>");
                item1.Text += string.Format("<tr><th colspan=\"2\"><b>Extra's</b></th></tr>");

                item1.Text += string.Format("<tr><td>Meeeten?</td><td>{0}</span></td></tr>", model.Food ? "Ja" : "Nee");
                item1.Text += string.Format("<tr><td>Kamperen</td><td>{0}</span></td></tr>", model.Camp ? "Interesse" : "Geen interesse");
                item1.Text += string.Format("<tr><td>Fiets stallen</td><td>{0}</span></td></tr>", model.Bike ? "Interesse" : "Geen interesse");
                item1.Text += string.Format("<tr><td>Finale</td><td>{0}</span></td></tr>", model.Finale=="W" ? "Ik ga ervoor!" : "Ik zie wel" );

                item1.Text += string.Format("<tr><td></td></tr>");
                item1.Text += string.Format("<tr><th colspan=\"2\"><b>Opmerkingen</b></th></tr>");

                item1.Text += string.Format("<tr><td>Opmerkingen</td><td>{0}</span></td></tr>", model.HebJeErZinIn ?? "-");
                item1.Text += string.Format("<tr><td>Opmerkingen voor speaker</td><td>{0}</span></td></tr>", model.OpmerkingenTbvSpeaker?? "-");
                item1.Text += string.Format("<tr><td>Opmerkingen voor organisatie</td><td>{0}</span></td></tr>", model.OpmerkingenAanOrganisatie ?? "-");

                item1.Text += string.Format("<tr><td></td></tr>");
                item1.Text += string.Format("<tr><th colspan=\"2\"><b>Inschrijfkosten</b></th></tr>");
                item1.Text += string.Format("<tr><td>Inschrijfgeld</td><td>{0}</span></td></tr>", model.BasisKosten.AsAmount() );
                item1.Text += string.Format("<tr><td>NTB Licentie</td><td>{0}</span></td></tr>", model.KostenNtbDagLicentie.AsAmount() );
                item1.Text += string.Format("<tr><td>MyLaps Chip</td><td>{0}</span></td></tr>", model.KostenChip.AsAmount());
                if (model.IsEarlyBird.HasValue && model.IsEarlyBird.Value) {
                    item1.Text += string.Format("<tr><td>Early Bird™ korting</td><td>{0}</span></td></tr>", model.EarlyBirdKorting.AsAmount());
                }
                item1.Text += string.Format("<tr><td>Avondeten</td><td>{0}</span></td></tr>", model.KostenEten.AsAmount());
                item1.Text += string.Format("<tr><td><b></b></td><td><span class=\"quotable\">------</span></td></tr>");
                item1.Text += string.Format("<tr><td><b>Totaal</b></td><td><span class=\"quotable\">{0}</span></td></tr>", model.InschrijfGeld.AsAmount());

                item1.Text += string.Format("<tr><td>Betaalwijze</td><td>{0}</span></td></tr>", model.Betaalwijze.Value.ToString());
                item1.Text += string.Format("<tr><td>Betaald?</td><td>{0}</span></td></tr>", model.DatumBetaald.HasValue ? model.DatumBetaald.Value.ToShortDateString() : "Nog niet");
                item1.Text += string.Format("<tr><td><b></b></td><td><span class=\"quotable\">------</span></td></tr>");
                item1.Text += string.Format("<tr><td><b>Totaal</b></td><td><span class=\"quotable\">{0}</span></td></tr>", model.InschrijfGeld.AsAmount());

                /*
                item1.Text += string.Format("<tr><td></td></tr>");
                item1.Text += string.Format("<tr><th colspan=\"2\"><b>Overmaken naar</b></th></tr>");

                item1.Text += string.Format("<tr><td>Bank rek nr</td><td><span class=\"quotable\">'1684.92.059'</span> (Rabobank)</td></tr>");
                item1.Text += string.Format("<tr><td>Ten name van </td><td><span class=\"quotable\">'Stichting Woelig Water'</span> (te Vinkeveen)</td></tr>");
                item1.Text += string.Format("<tr><td>Onder vermelding van</td><td><span class=\"quotable\">'H2RE {0}'</span></td></tr>", model.VolledigeNaam);
                */

                item1.Text += string.Format("</table></td></tr>");
                item1.Text += string.Format("</table>");

            newsletter.Items.Add(item1);

            SendPersonalNewsletterViewModel spnvm = new SendPersonalNewsletterViewModel();
            spnvm.IsEmail = true;
            spnvm.Newsletter = newsletter;

            MailMessage mm = new MailMessage();
            mm.From = new MailAddress(HreSettings.ReplyToAddress);
            mm.To.Add(new MailAddress(model.Email));

            // Send the confirmation mail to an appsetting defined admin email address for backup purposes.
            mm.Bcc.Add(new MailAddress(HreSettings.ConfirmationsCCAddress));

            if (!string.IsNullOrEmpty(model.OpmerkingenAanOrganisatie)) {
                mm.Bcc.Add(new MailAddress(HreSettings.MailAddressSecretary));
            }

            mm.Subject = model.DoForceSendConfirmationOfChange ?
                "Wijziging in inschrijfgegevens Hét Rondje Eilanden " + model.VolledigeNaam
                : "Aanmeldbevestiging deelname Hét Rondje Eilanden " + model.VolledigeNaam;

            mm.IsBodyHtml = true;
            spnvm.UserId = model.UserId;
            mm.Body = this.RenderNewsletterViewToString("../Newsletter/NewsletterTemplates/NewsletterTemplate", spnvm);
            EmailSender.SendEmail(mm, EmailCategory.SubscriptionConfirmation, model.ParticipationId, model.UserId);

            model.DateConfirmationSend = DateTime.Now;

            // Sla de entry nog een keer op, om ook de dateConfirmationSend op te slaan.
            // TODO BW 2013-03-01: Doe dit wat netter dan alles geheel twee keer opslaan.
            InschrijvingenRepository.SaveEntry(model, model.ExternalEventIdentifier, false, true);
        }
示例#7
0
 public ActionResult PreviewNewsletter(NewsletterViewModel nvm)
 {
     ViewBag.IsEmail = false;
     return View("NewsletterTemplates/NewsletterTemplate", nvm);
 }