Exemple #1
0
 internal static void ReadNewsletter(string newsletterSendItemGuid)
 {
     using (Vicdude_NewsletterEntities db = new Vicdude_NewsletterEntities())
     {
         var item = db.Newsletter_Send_Item.FirstOrDefault(n => n.NewsletterSendItemGUID == newsletterSendItemGuid);
         item.IsRead   = true;
         item.ReadDate = DateTime.Now;
         db.SaveChanges();
     }
 }
Exemple #2
0
 internal static void UpdateNewsletterSendItemToSent(int id)
 {
     using (Vicdude_NewsletterEntities db = new Vicdude_NewsletterEntities())
     {
         var item = db.Newsletter_Send_Item.FirstOrDefault(n => n.Id == id);
         item.IsSent   = true;
         item.SendDate = DateTime.Now;
         db.SaveChanges();
     }
 }
Exemple #3
0
 internal static void DeleteNewsletter(Newsletters newsletter)
 {
     try
     {
         using (Vicdude_NewsletterEntities db = new Vicdude_NewsletterEntities())
         {
             newsletter.IsDeleted       = true;
             db.Entry(newsletter).State = System.Data.Entity.EntityState.Modified;
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         LogHelper.LogError(string.Format("Error delete newsletter: {0}", newsletter.Id), ex, 0);
     }
 }
Exemple #4
0
        internal static void SaveNewsletter(Newsletters newsletter)
        {
            using (Vicdude_NewsletterEntities db = new Vicdude_NewsletterEntities())
            {
                if (newsletter.Id > 0)
                {
                    db.Entry(newsletter).State = System.Data.Entity.EntityState.Modified;
                }
                else
                {
                    newsletter.CreatedDate = DateTime.Now;
                    db.Newsletters.Add(newsletter);
                }

                db.SaveChanges();
            }
        }
Exemple #5
0
        internal static int CreateNewsletterSend(Newsletters newsletter, AccountSessionEntity accountSession)
        {
            using (Vicdude_NewsletterEntities db = new Vicdude_NewsletterEntities())
            {
                Newsletter_Send newsletterSend = new Newsletter_Send()
                {
                    ClubId             = accountSession.ClubId,
                    UserSendId         = accountSession.AccountId,
                    NewsletterContent  = newsletter.Content,
                    NewsletterId       = newsletter.Id,
                    NewsletterName     = newsletter.Name,
                    NewsletterSendGUID = Guid.NewGuid().ToString(),
                    SendDate           = DateTime.Now
                };

                db.Newsletter_Send.Add(newsletterSend);
                db.SaveChanges();
                return(newsletterSend.Id);
            }
        }
Exemple #6
0
        internal static void UnsubscribeNewsletterItem(Newsletter_Send_Item newsletterSendItem)
        {
            try
            {
                using (Vicdude_NewsletterEntities db = new Vicdude_NewsletterEntities())
                {
                    var item = db.Newsletter_Send_Item.FirstOrDefault(n => n.NewsletterSendItemGUID == newsletterSendItem.NewsletterSendItemGUID);
                    if (item != null)
                    {
                        item.HasUnsubscribed = true;

                        db.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.LogError(string.Format("Error updating newsletter send item to unsubscribed..."), ex, 0);
            }
        }
Exemple #7
0
        internal static void CreateNewsletterSendItems(int newsletterSendId, List <int> userIds, List <int> contactIds = null, int formFieldId = -1)
        {
            using (Vicdude_NewsletterEntities db = new Vicdude_NewsletterEntities())
            {
                foreach (int userId in userIds)
                {
                    Newsletter_Send_Item item = new Newsletter_Send_Item()
                    {
                        IsRead                 = false,
                        IsSent                 = false,
                        Email                  = SW.Core.BLL.AccountBLL.GetUserEmail(userId),
                        NewsletterSendId       = newsletterSendId,
                        NewsletterSendItemGUID = Guid.NewGuid().ToString(),
                        SendDate               = DateTime.Now,
                        SendToUserId           = userId,
                        ReadDate               = DateTime.Now.AddYears(-10),
                        HasUnsubscribed        = false,
                        SendType               = "USER"
                    };

                    db.Newsletter_Send_Item.Add(item);
                }

                if (contactIds != null && contactIds.Count > 0)
                {
                    foreach (int contactId in contactIds)
                    {
                        Newsletter_Send_Item item = new Newsletter_Send_Item()
                        {
                            IsRead                 = false,
                            IsSent                 = false,
                            Email                  = SW.Core.BLL.ContactBLL.GetContact(contactId).Email,
                            NewsletterSendId       = newsletterSendId,
                            NewsletterSendItemGUID = Guid.NewGuid().ToString(),
                            SendDate               = DateTime.Now,
                            SendToContactId        = contactId,
                            ReadDate               = DateTime.Now.AddYears(-10),
                            HasUnsubscribed        = false,
                            SendType               = "CONTACT"
                        };

                        db.Newsletter_Send_Item.Add(item);
                    }
                }

                if (formFieldId > 0)
                {
                    List <string> emails = FormsAdminBLL.GetExternalSubmitValues(formFieldId);

                    foreach (var email in emails)
                    {
                        Newsletter_Send_Item item = new Newsletter_Send_Item()
                        {
                            IsRead                 = false,
                            IsSent                 = false,
                            Email                  = email,
                            NewsletterSendId       = newsletterSendId,
                            NewsletterSendItemGUID = Guid.NewGuid().ToString(),
                            SendDate               = DateTime.Now,
                            ReadDate               = DateTime.Now.AddYears(-10),
                            HasUnsubscribed        = false,
                            SendType               = "FORM"
                        };

                        db.Newsletter_Send_Item.Add(item);
                    }
                }

                db.SaveChanges();
            }
        }