public ActionResult CreateNewsletter(NewsletterView newsletterView)
        {
            if (!string.IsNullOrEmpty(newsletterView.Subject) && !string.IsNullOrEmpty(newsletterView.HtmlBody))
            {
                var newsletter = Mapper.Map<NewsletterView, Newsletter>(newsletterView);
                newsletter.AddedBy = User.Identity.Name;
                newsletter.DateAdded = DateTime.Now;
                newsletter.Status = "Not Sent";
                newsletter.DateSent = null;
                using (var repository = _repositoryProvider.GetRepository())
                    repository.Save(newsletter);
                var config = Configuration.DessertHouseConfigurationSection.Current.Newsletters;
               var subscriberList = GetSubscriberList();

                var obj =
                    new NewsletterMessage { Newsletter = newsletter, FromEmail = config.FromEmail, FromEmailDisplayName = config.FromEmailDisplayName, EmailList=subscriberList };
                var emailThread = new Thread(_emailService.SendNewsLetter);
                emailThread.Start(obj);
                return RedirectToAction("ManageNewsletters", new { pendingUpdate = true });
            }
            ViewBag.PageTitle = "Create Newsletter";
            return View(new NewsletterView());
        }
        public ActionResult EditNewsletter(NewsletterView newsLetterView)
        {
            if (string.IsNullOrEmpty(newsLetterView.Subject) && string.IsNullOrEmpty(newsLetterView.HtmlBody))
            {
                ViewBag.PageTitle = "Edit Newsletter";
                return View("CreateNewsletter",newsLetterView);
            }

            Newsletter newsletter;
            using (var repository = _repositoryProvider.GetRepository())
            {
                newsletter = repository.Get<Newsletter>().Where(n => n.Id == newsLetterView.Id).FirstOrDefault();
                if (newsletter == null)
                    return HttpNotFound("Newsletter not found");

                newsletter.Subject = newsLetterView.Subject;
                newsletter.HtmlBody = newsLetterView.HtmlBody;
                newsletter.PlainTextBody = newsLetterView.PlainTextBody;
                repository.SaveOrUpdate(newsletter);
                var emailThread = new Thread(_emailService.SendNewsLetter);
                var config = Configuration.DessertHouseConfigurationSection.Current.Newsletters;
                IList<string> subscriberList = GetSubscriberList();

                dynamic obj =
                    new { Newsletter = newsletter, config.FromEmail, config.FromEmailDisplayName, subscriberList };
                emailThread.Start(obj);
                return RedirectToAction("ManageNewsletters",new{pendingUpdate=true});

            }
        }