예제 #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
 /// <summary>
 /// Constructor. Construct an e-mail newsletter object.
 /// </summary>
 public NewsletterDal(newsletter newsletter)
 {
     _newsletter = newsletter;
 }
예제 #3
0
        /// <summary>
        /// Initialize e-mail newsletter.
        /// </summary>
        public void Initialize()
        {
            // Initialize the newsletter if not found.
            if (_newsletter == null) {
                _newsletter = new newsletter();
                _newsletter.DateCreated = DateTime.Now;
            }

            // Try to retrieve the newsletter items with this newsletter.
            var newsletterItems = DB.newsletteritem.Where(e => e.NewsletterId == ID);

            // Set the newsletter items if found.
            if (newsletterItems.Count()==3) {
                Item1 = new NewsletterItemDal(newsletterItems.Where(e => e.SequenceNumber == 1).FirstOrDefault());
                Item2 = new NewsletterItemDal(newsletterItems.Where(e => e.SequenceNumber == 2).FirstOrDefault());
                Item3 = new NewsletterItemDal(newsletterItems.Where(e => e.SequenceNumber == 3).FirstOrDefault());
            } else {
                // Construct new items and add them to the newsletter.
                Item1 = new NewsletterItemDal(1);
                Item2 = new NewsletterItemDal(2);
                Item3 = new NewsletterItemDal(3);
            }
        }
예제 #4
0
 /// <summary>
 /// Constructor. Construct an e-mail newsletter object.
 /// </summary>
 public NewsletterDal()
 {
     _newsletter = new newsletter();
 }
예제 #5
0
 /// <summary>
 /// Deprecated Method for adding a new object to the newsletter EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddTonewsletter(newsletter newsletter)
 {
     base.AddObject("newsletter", newsletter);
 }
예제 #6
0
 /// <summary>
 /// Create a new newsletter object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="cultureId">Initial value of the CultureId property.</param>
 /// <param name="sequenceNumber">Initial value of the SequenceNumber property.</param>
 /// <param name="dateCreated">Initial value of the DateCreated property.</param>
 /// <param name="dateUpdated">Initial value of the DateUpdated property.</param>
 public static newsletter Createnewsletter(global::System.Int32 id, global::System.Int32 cultureId, global::System.Int32 sequenceNumber, global::System.DateTime dateCreated, global::System.DateTime dateUpdated)
 {
     newsletter newsletter = new newsletter();
     newsletter.Id = id;
     newsletter.CultureId = cultureId;
     newsletter.SequenceNumber = sequenceNumber;
     newsletter.DateCreated = dateCreated;
     newsletter.DateUpdated = dateUpdated;
     return newsletter;
 }