public BaseResponseAjaxModel Create(string email, string ip, string userAgent)
        {
            var responseData = new BaseResponseAjaxModel();

            bool emailAlreadyRegistered = this.newsletterRepos
                .All()
                .Where(n => n.Email == email)
                .Any();

            if (emailAlreadyRegistered)
            {
                responseData.ErrorMessage = string.Format("emai '{0}' is already registered for our newsletter.", email);
            }
            else
            {
                Newsletter dbNewsletter = new Newsletter()
                {
                    Email = email,
                    Ip = ip,
                    UserAgent = userAgent
                };

                this.newsletterRepos.Add(dbNewsletter);
                this.newsletterRepos.Save();

                responseData.Status = true;
            }

            return responseData;
        }
        public string cadastrarNews(string email) {

            try
            {

                Newsletter news = new Newsletter();
                news.Email = email;
                news.Data = DateTime.Now;
                news.Status = Utils.Enum.StatusEnum.ativo;


                var newsExists = db.Newsletter.Where(x => x.Email == email).FirstOrDefault();

                if (newsExists != null) {
                    return "0";
                }

                db.Newsletter.Add(news);
                db.SaveChanges();

                return "Email cadastrado com sucesso!";
            }
            catch (Exception error) {
                throw;
            }
          
        }
        public HttpResponseMessage update(Newsletter post)
        {
            // Check for errors
            if (post == null)
            {
                return Request.CreateResponse<string>(HttpStatusCode.BadRequest, "The post is null");
            }
            else if (Language.MasterPostExists(post.language_id) == false)
            {
                return Request.CreateResponse<string>(HttpStatusCode.BadRequest, "The language does not exist");
            }

            // Make sure that the data is valid
            post.title = AnnytabDataValidation.TruncateString(post.title, 100);
            post.sent_date = AnnytabDataValidation.TruncateDateTime(post.sent_date);

            // Get the saved post
            Newsletter savedPost = Newsletter.GetOneById(post.id);

            // Check if the post exists
            if (savedPost == null)
            {
                return Request.CreateResponse<string>(HttpStatusCode.BadRequest, "The record does not exist");
            }

            // Update the post
            Newsletter.Update(post);

            // Return the success response
            return Request.CreateResponse<string>(HttpStatusCode.OK, "The update was successful");

        } // End of the update method
        public void Should_create_organisation()
        {
            var newsletter = new Newsletter { Name = "Interne News" };

            var newsletterRepo = Resolve<NewsletterRepository>();
            newsletterRepo.Create(newsletter);

            Assert.That(newsletterRepo.GetAll().Count, Is.EqualTo(1));
            Assert.That(newsletterRepo.GetAll()[0].Name, Is.EqualTo("Interne News"));
        }
        internal static string Delete(int id) {
            try {
                EcommercePlatformDataContext db = new EcommercePlatformDataContext();
                Newsletter nw = new Newsletter();

                nw = db.Newsletters.Where(x => x.ID.Equals(id)).FirstOrDefault<Newsletter>();

                db.Newsletters.DeleteOnSubmit(nw);
                db.SubmitChanges();

                return "";
            } catch (Exception e) {
                return e.Message;
            }
        }
        /// <summary>
        ///A test for Insert
        ///</summary>
        //[TestMethod()]
        public void InsertTest()
        {
            NewsletterDAL target = new NewsletterDAL();
            Newsletter newsletter = new Newsletter();

            newsletter.IdNewsletter = 1;
            newsletter.Email = "*****@*****.**";
            newsletter.Data = DateTime.Now;
            

            target.Insert(newsletter);
            Newsletter newsletterTest = target.Obter("IdNewsletter = " + newsletter.IdNewsletter);

            Assert.AreEqual(newsletter.IdNewsletter,newsletterTest.IdNewsletter);
            Assert.AreEqual(newsletter.Email, newsletterTest.Email);
            Assert.AreEqual(newsletter.Data, newsletterTest.Data);
        }
        internal static void Add(string name, string email) {
            EcommercePlatformDataContext db = new EcommercePlatformDataContext();
            Newsletter exists = new Newsletter();

            // Check for existing
            exists = db.Newsletters.Where(x => x.Email.Equals(email)).FirstOrDefault<Newsletter>();
            if (exists != null) { throw new Exception("We are already sending the newsletter to " + email); }

            Newsletter nw = new Newsletter {
                Name = name,
                Email = email,
                DateAdded = DateTime.UtcNow,
                Unsubscribe = Guid.NewGuid()
            };
            db.Newsletters.InsertOnSubmit(nw);
            db.SubmitChanges();
        }
Beispiel #8
0
    } // End of the constructor

    #endregion

    #region Insert methods

    /// <summary>
    /// Add one newsletter post
    /// </summary>
    /// <param name="post">A reference to a newsletter post</param>
    public static void Add(Newsletter post)
    {
        // Create the connection and the sql statement
        string connection = Tools.GetConnectionString();
        string sql = "INSERT INTO dbo.newsletters (language_id, title, content, sent_date) "
            + "VALUES (@language_id, @title, @content, @sent_date);";

        // The using block is used to call dispose automatically even if there are an exception.
        using (SqlConnection cn = new SqlConnection(connection))
        {
            // The using block is used to call dispose automatically even if there are an exception.
            using (SqlCommand cmd = new SqlCommand(sql, cn))
            {
                // Add parameters
                cmd.Parameters.AddWithValue("@language_id", post.language_id);
                cmd.Parameters.AddWithValue("@title", post.title);
                cmd.Parameters.AddWithValue("@content", post.content);
                cmd.Parameters.AddWithValue("@sent_date", post.sent_date);
                
                // The Try/Catch/Finally statement is used to handle unusual exceptions in the code to
                // avoid having our application crash in such cases
                try
                {
                    // Open the connection
                    cn.Open();

                    // Execute the insert
                    cmd.ExecuteNonQuery();

                }
                catch (Exception e)
                {
                    throw e;
                }
            }
        }

    } // End of the Add method
    /// <summary>
    /// Initializes newsletter menu.
    /// </summary>
    /// <param name="news">Newsletter object</param>
    protected void InitalizeMenu(Newsletter news)
    {
        if (news != null)
        {
            string[,] tabs = null;

            if (news.NewsletterType == NewsletterType.Dynamic)
            {
                tabs = new string[4, 4];

                tabs[3, 0] = GetString("Newsletter_Header.Send");
                tabs[3, 1] = "SetHelpTopic('helpTopic', 'send_tab');";
                tabs[3, 2] = "Newsletter_Send.aspx?newsletterid=" + newsletterId;
            }
            else
            {
                tabs = new string[3, 4];
            }
            tabs[0, 0] = GetString("Newsletter_Header.Issues");
            tabs[0, 1] = "SetHelpTopic('helpTopic', 'issues_tab');";
            tabs[0, 2] = "Newsletter_Issue_List.aspx?newsletterid=" + newsletterId;
            tabs[1, 0] = GetString("Newsletter_Header.Configuration");
            tabs[1, 1] = "SetHelpTopic('helpTopic', 'configuration_tab');";
            tabs[1, 2] = "Newsletter_Configuration.aspx?newsletterid=" + newsletterId;
            tabs[2, 0] = GetString("Newsletter_Header.Subscribers");
            tabs[2, 1] = "SetHelpTopic('helpTopic', 'subscribers_tab');";
            tabs[2, 2] = "Newsletter_Subscribers.aspx?newsletterid=" + newsletterId;

            this.CurrentMaster.Tabs.Tabs = tabs;
            this.CurrentMaster.Tabs.UrlTarget = "newsletterContent";

            if (ValidationHelper.GetInteger(Request.QueryString["saved"], 0) > 0)
            {
                //user was redirected from Newsletter_New.aspx => show 'configuration' tab
                this.CurrentMaster.Tabs.SelectedTab = 1;
            }
        }
    }
        public HttpResponseMessage add(Newsletter post)
        {
            // Check for errors
            if (post == null)
            {
                return Request.CreateResponse<string>(HttpStatusCode.BadRequest, "The post is null");
            }
            else if (Language.MasterPostExists(post.language_id) == false)
            {
                return Request.CreateResponse<string>(HttpStatusCode.BadRequest, "The language does not exist");
            }

            // Make sure that the data is valid
            post.title = AnnytabDataValidation.TruncateString(post.title, 100);
            post.sent_date = AnnytabDataValidation.TruncateDateTime(post.sent_date);

            // Add the post
            Newsletter.Add(post);

            // Return the success response
            return Request.CreateResponse<string>(HttpStatusCode.OK, "The post has been added");

        } // End of the add method
    protected void Page_Load(object sender, EventArgs e)
    {
        newsletterId = QueryHelper.GetInteger("newsletterid", 0);
        if (newsletterId == 0)
        {
            RequestHelper.EndResponse();
        }

        string siteName = CMSContext.CurrentSiteName;
        mBounceMonitoringEnabled = SettingsKeyProvider.GetBoolValue(siteName + ".CMSMonitorBouncedEmails");
        mOnlineMarketingEnabled = NewsletterProvider.OnlineMarketingEnabled(siteName);

        ScriptHelper.RegisterDialogScript(this);

        string scriptBlock = string.Format(@"
            function RefreshPage() {{ document.location.replace(document.location); }}
            function EditItem(id) {{ modalDialog('{0}?issueid=' + id, 'NewsletterIssueEdit', screen.availWidth - 10, screen.availHeight - 80); }}
            function NewItem(id) {{ modalDialog('{1}?newsletterid=' + id, 'NewsletterNewIssue', screen.availWidth - 10, screen.availHeight - 80); }}
            function ShowOpenedBy(id) {{ modalDialog('{2}?issueid=' + id, 'NewsletterIssueOpenedBy', '900px', '700px');  return false; }}
            function ViewClickedLinks(id) {{ modalDialog('{3}?issueid=' + id, 'NewsletterTrackedLinks', '900px', '700px'); return false; }}",
            ResolveUrl(@"~\CMSModules\Newsletters\Tools\Newsletters\Newsletter_Issue_Frameset.aspx"),
            ResolveUrl(@"~\CMSModules\Newsletters\Tools\Newsletters\Newsletter_Issue_New_Edit.aspx"),
            ResolveUrl(@"~\CMSModules\Newsletters\Tools\Newsletters\Newsletter_Issue_OpenedBy.aspx"),
            ResolveUrl(@"~\CMSModules\Newsletters\Tools\Newsletters\Newsletter_Issue_TrackedLinks.aspx"));
        ScriptHelper.RegisterClientScriptBlock(this, GetType(), "Actions", scriptBlock, true);

        UniGrid.OnAction += uniGrid_OnAction;
        UniGrid.WhereCondition = "IssueNewsletterID = " + newsletterId;
        UniGrid.OnExternalDataBound += UniGrid_OnExternalDataBound;
        UniGrid.ZeroRowsText = GetString("Newsletter_Issue_List.NoIssuesFound");
        UniGrid.OnBeforeDataReload += UniGrid_OnBeforeDataReload;

        // Get newsletter object and check its existence
        EditedObject = newsletter = NewsletterProvider.GetNewsletter(newsletterId);

        InitHeaderActions();
    }
 public void Insert(Newsletter entity)
 {
     _newsletterRepository.Insert(entity);
 }
        public static void AddNewsletterSubscriber(this IDynamicsClient dynamicsClient, string slug, string email)
        {
            bool       newSubscriber = false;
            Newsletter newsletter    = dynamicsClient.GetNewsletterBySlug(slug);

            if (newsletter != null)
            {
                MicrosoftDynamicsCRMlead subscriber = dynamicsClient.GetSubscriberByEmail(email);
                if (subscriber == null)
                {
                    // add the new subscriber
                    MicrosoftDynamicsCRMlead newLead = new MicrosoftDynamicsCRMlead()
                    {
                        Emailaddress1 = email,
                        Firstname     = email
                    };

                    try
                    {
                        subscriber    = dynamicsClient.Leads.Create(newLead);
                        newSubscriber = true;
                    }
                    catch (HttpOperationException)
                    {
                        subscriber = null;
                    }
                    catch (Exception)
                    {
                        subscriber = null;
                    }
                }

                if (subscriber != null)
                {
                    // add the subscriber to the newsletter (Marketing List)

                    // check to determine if it is there already.
                    bool notFound = true;

                    if (subscriber.ListleadAssociation != null)
                    {
                        foreach (var item in subscriber.ListleadAssociation)
                        {
                            if (item.Listid == newsletter.Id.ToString())
                            {
                                notFound = false;
                            }
                        }
                    }

                    if (notFound)
                    {
                        try
                        {
                            EntityIdReference oDataId = new EntityIdReference()
                            {
                                EntityId = subscriber.Leadid
                            };
                            dynamicsClient.Lists.AddMember(newsletter.Id.ToString(), oDataId);
                        }
                        catch (HttpOperationException)
                        {
                            throw;
                        }
                    }
                }
            }
        }
        public ActionResult RegAjx(RegisterAjxModel model)
        {
            if (ModelState.IsValid)
            {
                MembershipCreateStatus createStatus;
                MembershipUser         newUser = Membership.CreateUser(model.Email, model.Password, model.Email, "-", "-", true, out createStatus);

                if (createStatus != MembershipCreateStatus.Success)
                {
                    ModelState.AddModelError(string.Empty, RP.T("Account.Register.Error." + createStatus.ToString()).ToString());
                }
                else
                {
                    User u = _db.Users.FirstOrDefault(r => r.UserName == model.Email);
                    u.Roles       = SF.RolesStringAdd(u.Roles, "Register");
                    u.FirstName   = model.FirstName.Trim();
                    u.LastName    = model.LastName.Trim();
                    u.RoleDefault = "Register";
                    if (Session["address"] != null)
                    {
                        u.AddressMap = (string)Session["address"];
                    }
                    if (Session["longitude"] != null)
                    {
                        u.Longitude = (decimal)Session["longitude"];
                    }
                    if (Session["latitude"] != null)
                    {
                        u.Latitude = (decimal)Session["latitude"];
                    }

                    u.IsApproved       = true;
                    _db.Entry(u).State = EntityState.Modified;
                    _db.SaveChanges();
                    if (model.NewsLetter)
                    {
                        Newsletter n = new Newsletter()
                        {
                            NewsletterAccept = true,
                            NewsletterDate   = DateTime.UtcNow,
                            NewsletterEmail  = u.Email,
                            NewsletterName   = u.FirstName + " " + u.LastName,
                            RoleDefault      = "Register"
                        };
                        _db.Newsletters.Add(n);
                        _db.SaveChanges();
                        SF.AddToNewsletter(n);
                    }
                    if (Membership.ValidateUser(u.UserName, u.Password))
                    {
                        LS.Authorize(u);
                        var messService = new MessageService(_db);

                        messService.SendUserRegisterEmailToUser(u);
                        return(Json(new { result = "ok", url = "" }));
                    }
                    else
                    {
                        ModelState.AddModelError("", RP.T("Account.Logon.PasswordOrUserIncorrect").ToString());
                    }
                }
            }
            return(Json(new { result = "error", message = ModelState.Values.Select(x => new { Value = x.Value != null ? x.Value.AttemptedValue : "", errors = x.Errors.Select(y => y.ErrorMessage) }) }));

            //for future needed
            //   return Json(new { result = "error", message = new Dictionary<string,List<string>>().Select(x=> new { Value = x.Key,errors=x.Value  }) });
        }
Beispiel #15
0
        /// Function Header*******************************************************
        /// Function Name: SaveNewsletter
        /// Function Type: Function
        /// Functionality: used to save the details of newsletters
        /// Input: 
        /// Output: 
        /// Return Value:
        /// Note: 
        /// *********************************************************************
        public int SaveNewsletter(Entity.NewsInfo oNewsInfo)
        {
            using (TLWDALDataContext _db = new TLWDALDataContext())
            {
                int intRetVal = 1;
                var _varDup = _db.Newsletters.Where(x => x.strTitle.ToLower().Equals(oNewsInfo.StrTitle.ToLower())
                                       && x.chrIsDeleted.Equals('N')
                                   ).SingleOrDefault();
                if (_varDup != null)
                {
                    intRetVal = -1;
                    oNewsInfo = null;
                    _varDup = null;
                }
                else
                {
                    DAL.Newsletter oNewslettersDAL = new Newsletter();
                    oNewslettersDAL.strTitle = oNewsInfo.StrTitle;
                    oNewslettersDAL.chrIsDeleted = 'N';
                    oNewslettersDAL.chrIsActive = oNewsInfo.ChrIsActive;
                    if (!oNewsInfo.StrNewsletterDate.ToString().Equals("1/1/1999 12:00:00 AM"))
                        oNewslettersDAL.strNewsletterDate = oNewsInfo.StrNewsletterDate;

                    oNewslettersDAL.dtCreatedOn = oNewsInfo.DtCreatedOn;
                    oNewslettersDAL.dtModifiedOn = oNewsInfo.DtCreatedOn;
                    oNewslettersDAL.strDescription = oNewsInfo.StrDescription;

                    if (oNewsInfo.StrPDFFilename.Equals(string.Empty))
                        oNewslettersDAL.strPDFFileName = "na.pdf";
                    else
                        oNewslettersDAL.strPDFFileName = oNewsInfo.StrPDFFilename;

                    _db.Newsletters.InsertOnSubmit(oNewslettersDAL);
                    _db.SubmitChanges();

                    intRetVal = oNewslettersDAL.intNewsLetterId;
                    oNewslettersDAL = null;
                    oNewsInfo = null;
                }

                return intRetVal;
            }
        }
 public override void Setup()
 {
     base.Setup();
     DefaultAct        = Act.CreateDefault();
     DefaultNewsletter = Newsletter.CreateDefault();
     DefaultSeries     = Series.CreateDefault();
     Baker             = new Artist {
         QueryHelper = QueryHelper,
         Surname     = BakerName
     };
     Drums = new Role {
         QueryHelper = QueryHelper,
         Name        = DrumsName
     };
     Location1 = new Location {
         QueryHelper = QueryHelper,
         Name        = Location1Name
     };
     Event1 = new Event {
         QueryHelper = QueryHelper,
         Date        = DateTime.Parse("2020/03/01")
     };
     Set1 = new Set {
         QueryHelper = QueryHelper,
         SetNo       = Set1SetNo
     };
     Set2 = new Set {
         QueryHelper = QueryHelper,
         SetNo       = Set2SetNo
     };
     Piece1 = new Piece {
         QueryHelper = QueryHelper,
         PieceNo     = Piece1PieceNo,
         AudioUrl    = Piece1AudioUrl,
         Duration    = Piece1Duration = new TimeSpan(0, 5, 29),
         Notes       = Piece1Notes,
         Title       = Piece1Title,
         VideoUrl    = Piece1VideoUrl
     };
     Piece1AtSet2 = new Piece {
         QueryHelper = QueryHelper,
         PieceNo     = Piece1PieceNo,
         Duration    = Piece1AtSet2Duration = new TimeSpan(0, 2, 8)
     };
     Piece2 = new Piece {
         QueryHelper = QueryHelper,
         PieceNo     = Piece2PieceNo,
         Duration    = Piece2Duration = new TimeSpan(1, 46, 3)
     };
     Credit1 = new Credit {
         QueryHelper = QueryHelper,
         CreditNo    = Credit1CreditNo
     };
     Credit2 = new Credit {
         QueryHelper = QueryHelper,
         CreditNo    = Credit2CreditNo
     };
     Session.BeginUpdate();
     Session.Persist(DefaultAct);
     Session.Persist(DefaultNewsletter);
     Session.Persist(DefaultSeries);
     Session.Persist(Baker);
     Session.Persist(Drums);
     Session.Persist(Location1);
     Event1.Location = Location1;
     Data.AddEventTypesPersisted(1, Session);
     Event1.EventType = Data.EventTypes[0];
     Session.Persist(Event1);
     Set1.Event = Event1;
     Set2.Event = Event1;
     Data.AddGenresPersisted(1, Session);
     Set1.Genre = Data.Genres[0];
     Set2.Genre = Set1.Genre;
     Session.Persist(Set1);
     Session.Persist(Set2);
     Piece1.Set       = Set1;
     Piece1AtSet2.Set = Set2;
     Piece2.Set       = Set1;
     Session.Persist(Piece1);
     Session.Persist(Piece1AtSet2);
     Session.Persist(Piece2);
     Credit1.Artist = Baker;
     Credit1.Piece  = Piece1;
     Credit1.Role   = Drums;
     Credit2.Artist = Baker;
     Credit2.Piece  = Piece1;
     Credit2.Role   = Drums;
     Session.Persist(Credit1);
     Session.Persist(Credit2);
     Session.Commit();
     Session.BeginRead();
     Location1    = QueryHelper.Read <Location>(Location1Name, Session);
     Event1       = QueryHelper.Read <Event>(Event1.SimpleKey, Location1, Session);
     Set1         = QueryHelper.Read <Set>(Set1.SimpleKey, Event1, Session);
     Set2         = QueryHelper.Read <Set>(Set2.SimpleKey, Event1, Session);
     Piece1       = QueryHelper.Read <Piece>(Piece1SimpleKey, Set1, Session);
     Piece1AtSet2 = QueryHelper.Read <Piece>(Piece1SimpleKey, Set2, Session);
     Piece2       = QueryHelper.Read <Piece>(Piece2SimpleKey, Set1, Session);
     Credit1      = QueryHelper.Read <Credit>(Credit1.SimpleKey, Piece1, Session);
     Credit2      = QueryHelper.Read <Credit>(Credit2.SimpleKey, Piece1, Session);
     Session.Commit();
 }
Beispiel #17
0
 public async Task UpdateAsync(Newsletter newsletter)
 {
     _context.Entry(newsletter).State = EntityState.Modified;
     await _context.SaveChangesAsync();
 }
Beispiel #18
0
    public string Get_Newsletter_E(string token)
    {
        if (!CheckToken(token))
        {
            return("Erreur de Token");
        }
        else
        {
            try
            {
                StringBuilder sb = new StringBuilder();

                Newsletter n = DataMapping.GetNewsletter_By_status("E");

                if (n != null)
                {
                    List <Newsletter_Out> Liste = DataMapping.Get_Recipient_by_Newsletter_id(n.id, "A");
                    if (Liste != null)
                    {
                        if (Liste.Count > 0)
                        {
                            Newsletter_Out n_o = Liste[0] as Newsletter_Out;
                            //foreach (Newsletter_Out n_o in Liste)
                            //{
                            List <System.Net.Mail.Attachment> att = new List <System.Net.Mail.Attachment>();
                            PortalSettings ps           = PortalController.GetCurrentPortalSettings();
                            bool           resultat_MAJ = true;
                            try
                            {
                                MailMessage message = new MailMessage(new MailAddress(ps.Email, ps.PortalName), new MailAddress(n_o.email, ""));
                                //message.ReplyTo = new MailAddress(newsletter.replyemail, newsletter.fromname);
                                message.ReplyToList.Add(new MailAddress(n.sender_email, n.sender_name));
                                message.Subject    = n.title;
                                message.IsBodyHtml = true;

                                message.Body         = ReplaceUrls(n.text, n_o.id);
                                message.BodyEncoding = Encoding.UTF8;
                                message.Headers.Add("X-AIS-Ref", n.id);
                                message.DeliveryNotificationOptions =
                                    DeliveryNotificationOptions.OnFailure |
                                    DeliveryNotificationOptions.OnSuccess |
                                    DeliveryNotificationOptions.Delay;
                                message.Headers.Add("Disposition-Notification-To", ps.Email);

                                string SMTPServer = "" + ps.HostSettings["SMTPServer"];
                                int    portPos    = SMTPServer.IndexOf(":");
                                int    SMTPPort   = 25;
                                if (portPos > -1)
                                {
                                    SMTPPort   = int.Parse(SMTPServer.Substring(portPos + 1, SMTPServer.Length - portPos - 1));
                                    SMTPServer = SMTPServer.Substring(0, portPos);
                                }

                                SmtpClient client = new SmtpClient(SMTPServer, SMTPPort);
                                client.UseDefaultCredentials = false;
                                //client.Credentials = new NetworkCredential("" + ps.HostSettings["SMTPUsername"], "" + ps.HostSettings["SMTPPassword"]);
                                client.Credentials = new NetworkCredential(GetSMTPEmail(), GetSMTPPassword());
                                client.Send(message);
                                message.Dispose();

                                sb.AppendLine("Succes de l'envoie du mail : " + n_o.email + ", newsletter : " + n.title);
                                n_o.status   = "T";
                                n_o.error    = "";
                                resultat_MAJ = DataMapping.Update_Newsletter_Out(n_o);
                            }
                            catch (Exception ee)
                            {
                                sb.AppendLine("Erreur lors de l'envoie du mail : " + n_o.email + ", newsletter : " + n.title);
                                n_o.status   = "E";
                                n_o.error    = ee.Message;
                                resultat_MAJ = DataMapping.Update_Newsletter_Out(n_o);
                            }


                            //string result = Mail.SendEmail(GetAdminEmail(), GetAdminEmail(), n_o.email, n.titre, n.texte, att);
                            ////string result = Mail.SendMail(HostEmail, n.email, "", "", "", MailPriority.Normal, n.la_Newsletter.titre, MailFormat.Html, System.Text.Encoding.UTF8, n.la_Newsletter.texte, att, SMTPServer, SMTPAuthentication, SMTPUsername, SMTPPassword, false);

                            //bool resultat_MAJ = true;
                            //if (!string.IsNullOrEmpty(result))
                            //{
                            //    sb.AppendLine("Erreur lors de l'envoie du mail id = " + n_o.id.ToString());
                            //    n_o.statut = "E";
                            //    n_o.erreur = result;
                            //    resultat_MAJ = DataMapping.Update_Newsletter_Out(n_o);
                            //}
                            //else
                            //{
                            //    sb.AppendLine("Succes de l'envoie du mail id = " + n_o.id.ToString());
                            //    n_o.statut = "T";
                            //    n_o.erreur = "";
                            //    resultat_MAJ = DataMapping.Update_Newsletter_Out(n_o);
                            //}

                            if (resultat_MAJ == false)
                            {
                                sb.AppendLine("Erreur lors de la MAJ du mail : " + n_o.email + ", newsletter : " + n.title);
                            }

                            //   Thread.Sleep(5000);
                            //} //end foreach
                        }
                        else
                        {
                            n.status = "T";

                            bool retour = DataMapping.UpdateNewsletter(n);

                            if (retour == true)
                            {
                                sb.AppendLine("");
                            }
                            else
                            {
                                sb.AppendLine("Problème lors de la mise à jour de la newsletter " + n.title);
                            }

                            return("Pas de mails à envoyer");
                        }
                    }
                    else
                    {
                        return("Problème lors de la récupération des mails");
                    }
                }
                else
                {
                    sb.AppendLine("Pas de newsletter en attente.");
                }


                return(sb.ToString());
            }
            catch (Exception ee)
            {
                return(ee.Message);
            }
        }
    }
Beispiel #19
0
        public JsonResult Subscribe(string slug)
        {
            Newsletter newsletter = db.GetNewsletterBySlug(slug);

            return(Json(newsletter));
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        InitGUI();

        // Get issue ID from query string
        int newsletterIssueId = QueryHelper.GetInteger("issueid", 0);

        // Get Issue object
        Issue issue = IssueProvider.GetIssue(newsletterIssueId);

        if (issue == null)
        {
            lblError.Visible = true;
            lblError.Text    = GetString("Newsletter_Issue_New_Preview.NoIssue");

            return;
        }

        // Get specific number of subscribers subscribed to the newsletter
        string where = "SubscriberID IN (SELECT SubscriberID FROM Newsletter_SubscriberNewsletter WHERE NewsletterID=" + issue.IssueNewsletterID + " AND (SubscriptionApproved = 1 OR SubscriptionApproved IS NULL))";
        DataSet subscribers = SubscriberProvider.GetSubscribers(where, null, MAX_PREVIEW_SUBSCRIBERS, null);

        string script;

        if (!DataHelper.DataSourceIsEmpty(subscribers))
        {
            // Limit max subscribers count to number of rows
            int maxCount = subscribers.Tables[0].Rows.Count;

            // Generate javascript based on subscribers
            script = string.Format(@"newsletterIssueId ={0};
                                     var guid = new Array({1});
                                     var email = new Array({1});
                                     var subject = new Array({1});
                                     var subscribers = new Array(guid, email);",
                                   newsletterIssueId,
                                   maxCount);

            // Ensure correct subject culture
            string siteName = CMSContext.CurrentSiteName;
            string culture  = CultureHelper.GetDefaultCulture(siteName);

            // Get newsletter object
            Newsletter news = NewsletterProvider.GetNewsletter(issue.IssueNewsletterID);

            // Get subject base
            string subjectBase = GetString("general.subject") + ResHelper.Colon;

            Subscriber subscriber = null;
            Subscriber sb         = null;
            SortedDictionary <int, Subscriber> subMembers = null;
            string      infoLine = null;
            string      subject  = null;
            IssueHelper ih       = new IssueHelper();

            for (int i = 0; i < maxCount; i++)
            {
                // Get subscriber
                subscriber = new Subscriber(subscribers.Tables[0].Rows[i]);
                if (subscriber != null)
                {
                    // Insert subscriber GUID
                    script = string.Format("{0} guid[{1}] = '{2}'; \n ", script, i, subscriber.SubscriberGUID);

                    // Get subscriber's member (different for user, role or contact group subscribers)
                    subMembers = SubscriberProvider.GetSubscribers(subscriber, 1, 0);
                    foreach (KeyValuePair <int, Subscriber> item in subMembers)
                    {
                        // Get 1st subscriber's member
                        sb = item.Value;
                        if (sb != null)
                        {
                            // Create information line
                            infoLine = ScriptHelper.GetString(sb.SubscriberEmail, false);

                            // Add info about subscriber type
                            if (sb.SubscriberType == SiteObjectType.USER)
                            {
                                infoLine = string.Format("{0} ({1})", infoLine, GetString("objecttype.cms_user").ToLower());
                            }
                            else if (sb.SubscriberType == SiteObjectType.ROLE)
                            {
                                infoLine = string.Format("{0} ({1})", infoLine, GetString("objecttype.cms_role").ToLower());
                            }
                            else if (sb.SubscriberType == PredefinedObjectType.CONTACTGROUP)
                            {
                                infoLine = string.Format("{0} ({1})", infoLine, GetString("objecttype.om_contactgroup").ToLower());
                            }

                            script = string.Format("{0} email[{1}] = '{2}'; \n ", script, i, infoLine);

                            // Resolve dynamic field macros ({%FirstName%}, {%LastName%}, {%Email%})
                            if (ih.LoadDynamicFields(sb, news, null, issue, true, siteName, null, null, null))
                            {
                                subject = ih.ResolveDynamicFieldMacros(issue.IssueSubject);
                            }

                            // Create resolved subject
                            subject = HTMLHelper.HTMLEncode(string.Format("{0} {1}", subjectBase, subject));
                            script  = string.Format("{0}subject[{1}] = {2}; \n ", script, i, ScriptHelper.GetString(subject));
                        }
                    }
                }
            }
        }
        else
        {
            // No subscribers? => hide 'prev' and 'next' link buttons
            pnlLinkButtons.Visible = false;

            // Generate void javascript
            script = string.Format(@"newsletterIssueId ={0};
                                     var guid = new Array(1);
                                     var email = new Array(1);
                                     var subscribers = new Array(guid, email);
                                     guid[1] = 0;
                                     email[1] = 0;",
                                   newsletterIssueId);
        }
        ltlScript.Text = ScriptHelper.GetScript(script);

        if (!RequestHelper.IsPostBack())
        {
            ScriptHelper.RegisterStartupScript(this, typeof(string), "LoadPreview" + ClientID, ScriptHelper.GetScript("pageLoad();"));
        }
    }
Beispiel #21
0
 public void Insert(Newsletter entity)
 {
     newsletterRepository.Insert(entity);
     unitOfWork.SaveChanges();
 }
 public IActionResult Create(Newsletter newsletter)
 {
     _db.Newsletters.Add(newsletter);
     _db.SaveChanges();
     return(RedirectToAction("Index"));
 }
Beispiel #23
0
 public void Delete(Newsletter entity)
 {
     newsletterRepository.Delete(entity);
     unitOfWork.SaveChanges();
 }
Beispiel #24
0
 public Task Create(Newsletter newsletter)
 {
     _context.NewsLetters.Add(newsletter);
     return(_context.SaveChangesAsync());
 }
    /// <summary>
    /// Creates and sends unsubscription e-mail.
    /// </summary>
    /// <param name="subscriber">Subscriber object</param>
    /// <param name="news">Newsletter object</param>
    /// <param name="subscription">Subscription object</param>
    /// <param name="siteName">Site name</param>
    protected void SendUnsubscriptionRequest(Subscriber subscriber, Newsletter news, SubscriberNewsletterInfo subscription, string siteName)
    {
        // Get global e-mail template with unsubscription request
        EmailTemplateInfo et = CMS.EmailEngine.EmailTemplateProvider.GetEmailTemplate("newsletter.unsubscriptionrequest", siteName);
        if (et != null)
        {
            // Get subscriber member
            SortedDictionary<int, Subscriber> subscribers = SubscriberProvider.GetSubscribers(subscriber, 1, 0);
            foreach (KeyValuePair<int, Subscriber> item in subscribers)
            {
                // Get 1st subscriber's member
                Subscriber sb = item.Value;

                string body = et.TemplateText;
                string plainBody = et.TemplatePlainText;

                // Resolve newsletter macros (first name, last name etc.)
                IssueHelper ih = new IssueHelper();
                if (ih.LoadDynamicFields(sb, news, subscription, null, false, siteName, null, null, null))
                {
                    body = ih.ResolveDynamicFieldMacros(body);
                    plainBody = ih.ResolveDynamicFieldMacros(plainBody);
                }

                // Create e-mail
                EmailMessage msg = new EmailMessage();
                msg.EmailFormat = EmailFormatEnum.Default;
                msg.From = EmailHelper.GetSender(et, news.NewsletterSenderEmail);
                msg.Recipients = sb.SubscriberEmail;
                msg.BccRecipients = et.TemplateBcc;
                msg.CcRecipients = et.TemplateCc;
                msg.Subject = ResHelper.LocalizeString(et.TemplateSubject);
                msg.Body = URLHelper.MakeLinksAbsolute(body);
                msg.PlainTextBody = URLHelper.MakeLinksAbsolute(plainBody);

                // Add attachments and send e-mail
                MetaFileInfoProvider.ResolveMetaFileImages(msg, et.TemplateID, EmailObjectType.EMAILTEMPLATE, MetaFileInfoProvider.OBJECT_CATEGORY_TEMPLATE);

                EmailSender.SendEmail(siteName, msg);
            }
        }
        else
        {
            // Log missing template
            EventLogProvider ev = new EventLogProvider();
            ev.LogEvent(EventLogProvider.EVENT_TYPE_ERROR, DateTime.Now, "UnsubscriptionRequest", "Unsubscription request e-mail template is missing.");
        }
    }
Beispiel #26
0
        public string SaveModule(BaseModule module, string pageid, string newsletterid, string languageCode)
        {
            BaseService.CheckLoginAndLicense();
            module.Site = SessionObject.CurrentSite;
            CmsPage    page       = (pageid != null && pageid != "") ? BaseObject.GetById <CmsPage>(new Guid(pageid)) : null;
            Newsletter newsletter = (newsletterid != null && newsletterid != "") ? BaseObject.GetById <Newsletter>(new Guid(newsletterid)) : null;

            if (module.CrossPagesMode == CrossPagesModeEnum.VisibleOnAllPages)
            {
                module.Template = null;
                //module.Pages = SessionObject.CurrentSite.Pages;
                //module.Page = null;
            }
            else if (module.CrossPagesMode == CrossPagesModeEnum.VisibleOnAllPagesInTemplate)
            {
                if (pageid != null && pageid != "")
                {
                    module.Template = page.Template;
                }
                else
                {
                    module.Template = newsletter.Template;
                }
            }
            else
            {
                if (pageid != null && pageid != "")
                {
                    //if (!module.hasReferenceToPage(Guid.Parse(pageid)))
                    //{
                    //    CmsPage page = BaseObject.GetById<CmsPage>(new Guid(pageid));
                    //    module.Pages.Add(page);
                    //}
                    //module.Page = new CmsPage();
                    //module.Page.ID = new Guid(pageid);
                }
                else
                {
                    module.Newsletter    = new Newsletter();
                    module.Newsletter.ID = new Guid(newsletterid);
                }
            }
            module.Save();
            //SetUnpublishedItem(module);
            module = module.ConvertToType();

            //lijst van ObjectPermissions wordt hier alleen als drager gebruikt.
            //in de licentieserver wordt deze lijst weer gesplitst en in 2 tabellen gezet
            //BaseCollection<ObjectPermission> objPermissions = module.GetObjectPermissions4LicenseServer();
            //if (objPermissions.Count > 0)
            //{
            //    BitAutorisationService.AutorisationClient client = BitMetaServerServicesHelper.GetClient();
            //    client.SaveObjectPermissions(objPermissions);
            //}

            module.LanguageCode = languageCode;
            //Where needs the module to be published?
            string returnValue = "";

            if (page != null)
            {
                returnValue = module.Publish2(page);
            }
            else
            {
                returnValue = module.Publish2(newsletter);
            }
            return(returnValue);
        }
    protected void btnOK_Click(object sender, EventArgs e)
    {
        // Check "configure" permission
        if (!CMSContext.CurrentUser.IsAuthorizedPerResource("cms.newsletter", "configure"))
        {
            RedirectToCMSDeskAccessDenied("cms.newsletter", "configure");
        }

        string errorMessage = ValidateNewsletterValues();

        if (!string.IsNullOrEmpty(errorMessage))
        {
            ShowError(errorMessage);
            return;
        }

        Newsletter newsletterObj = NewsletterProvider.GetNewsletter(txtNewsletterName.Text.Trim(), CMSContext.CurrentSiteID);

        // Newsletter's code name must be unique
        if (newsletterObj != null && newsletterObj.NewsletterID != newsletterId)
        {
            ShowError(GetString("Newsletter_Edit.NewsletterNameExists"));
            return;
        }

        if (newsletterObj == null)
        {
            newsletterObj = NewsletterProvider.GetNewsletter(newsletterId);
        }

        SetNewsletterValues(newsletterObj);

        // Check if subscription template was selected
        int subscriptionTemplateValue = ValidationHelper.GetInteger(subscriptionTemplate.Value, 0);

        if (subscriptionTemplateValue == 0)
        {
            ShowError(GetString("Newsletter_Edit.NoSubscriptionTemplateSelected"));
            return;
        }
        newsletterObj.NewsletterSubscriptionTemplateID = subscriptionTemplateValue;

        // Check if double opt-in template was selected
        int optInTemplateValue = ValidationHelper.GetInteger(optInSelector.Value, 0);

        if (newsletterObj.NewsletterEnableOptIn && optInTemplateValue == 0)
        {
            ShowError(GetString("Newsletter_Edit.NoOptInTemplateSelected"));
            return;
        }
        newsletterObj.NewsletterOptInTemplateID = optInTemplateValue;

        // Check if unsubscription template was selected
        int unsubscriptionTemplateValue = ValidationHelper.GetInteger(unsubscriptionTemplate.Value, 0);

        if (unsubscriptionTemplateValue == 0)
        {
            ShowError(GetString("Newsletter_Edit.NoUnsubscriptionTemplateSelected"));
            return;
        }
        newsletterObj.NewsletterUnsubscriptionTemplateID = unsubscriptionTemplateValue;

        // ID of scheduled task which should be deleted
        int deleteScheduledTaskId = 0;

        if (isDynamic)
        {
            newsletterObj.NewsletterType           = NewsletterType.Dynamic;
            newsletterObj.NewsletterDynamicURL     = txtNewsletterDynamicURL.Text.Trim();
            newsletterObj.NewsletterDynamicSubject = radFollowing.Checked ? txtSubject.Text : string.Empty;

            if (chkSchedule.Checked)
            {
                // Set info for scheduled task
                TaskInfo task = GetDynamicNewsletterTask(newsletterObj);

                if (!schedulerInterval.CheckOneDayMinimum())
                {
                    // If problem occurred while setting schedule interval
                    ShowError(GetString("Newsletter_Edit.NoDaySelected"));
                    return;
                }

                if (!IsValidDate(SchedulingHelper.DecodeInterval(schedulerInterval.ScheduleInterval).StartTime))
                {
                    ShowError(GetString("Newsletter.IncorrectDate"));
                    return;
                }

                task.TaskInterval = schedulerInterval.ScheduleInterval;

                task.TaskNextRunTime = SchedulingHelper.GetNextTime(task.TaskInterval, new DateTime(), new DateTime());
                task.TaskDisplayName = GetString("DynamicNewsletter.TaskName") + newsletterObj.NewsletterDisplayName;
                task.TaskName        = "DynamicNewsletter_" + newsletterObj.NewsletterName;
                // Set task for processing in external service
                task.TaskAllowExternalService = true;
                task.TaskUseExternalService   = (SchedulingHelper.UseExternalService && NewsletterProvider.UseExternalServiceForDynamicNewsletters(CMSContext.CurrentSiteName));
                TaskInfoProvider.SetTaskInfo(task);
                newsletterObj.NewsletterDynamicScheduledTaskID = task.TaskID;
            }
            else
            {
                if (newsletterObj.NewsletterDynamicScheduledTaskID > 0)
                {
                    // Store task ID for deletion
                    deleteScheduledTaskId = newsletterObj.NewsletterDynamicScheduledTaskID;
                }
                newsletterObj.NewsletterDynamicScheduledTaskID = 0;
                schedulerInterval.Visible = false;
            }
        }
        else
        {
            newsletterObj.NewsletterType = NewsletterType.TemplateBased;

            // Check if issue template was selected
            int issueTemplateValue = ValidationHelper.GetInteger(issueTemplate.Value, 0);
            if (issueTemplateValue == 0)
            {
                ShowError(GetString("Newsletter_Edit.NoEmailTemplateSelected"));
                return;
            }
            newsletterObj.NewsletterTemplateID = issueTemplateValue;
        }

        // Save changes to DB
        NewsletterProvider.SetNewsletter(newsletterObj);
        if (deleteScheduledTaskId > 0)
        {
            // Delete scheduled task if schedule mail-outs were unchecked
            TaskInfoProvider.DeleteTaskInfo(deleteScheduledTaskId);
        }

        ShowInformation(GetString("General.ChangesSaved"));

        // Refresh header with display name
        ScriptHelper.RefreshTabHeader(Page, GetString("Newsletter_Header.Configuration"));
    }
Beispiel #28
0
        public async Task CreateAsync(Newsletter newsletter)
        {
            await _context.Newsletter.AddAsync(newsletter);

            await _context.SaveChangesAsync();
        }
 private static TaskInfo GetDynamicNewsletterTask(Newsletter newsletterObj)
 {
     return(TaskInfoProvider.GetTaskInfo(ValidationHelper.GetInteger(newsletterObj.NewsletterDynamicScheduledTaskID, 0)) ??
            CreateDynamicNewsletterTask(newsletterObj));
 }
Beispiel #30
0
 public async Task DeleteAsync(Newsletter newsletter)
 {
     newsletter.IsDeleted = true;
     await UpdateAsync(newsletter);
 }
    protected void LoadData()
    {
        // Get newsletter object and check if exists
        Newsletter newsletterObj = NewsletterProvider.GetNewsletter(newsletterId);

        EditedObject = newsletterObj;

        // Initialize issue selectors
        int siteId = newsletterObj.NewsletterSiteID;

        subscriptionTemplate.WhereCondition   = "TemplateType='S' AND TemplateSiteID=" + siteId;
        unsubscriptionTemplate.WhereCondition = "TemplateType='U' AND TemplateSiteID=" + siteId;
        issueTemplate.WhereCondition          = "TemplateType='I' AND TemplateSiteID=" + siteId;
        optInSelector.WhereCondition          = "TemplateType='D' AND TemplateSiteID=" + siteId;

        // Check if the newsletter is dynamic and adjust config dialog
        isDynamic = newsletterObj.NewsletterType == NewsletterType.Dynamic;

        lblDynamic.Visible = pnlDynamic.Visible = lblNewsletterDynamicURL.Visible =
            txtNewsletterDynamicURL.Visible = plcUrl.Visible = chkSchedule.Visible =
                lblSchedule.Visible         = plcInterval.Visible = isDynamic;

        lblTemplateBased.Visible = lblIssueTemplate.Visible = issueTemplate.Visible = !isDynamic;

        if (RequestHelper.IsPostBack())
        {
            if (isDynamic)
            {
                schedulerInterval.Visible = chkSchedule.Checked;
            }
            else
            {
                plcInterval.Visible = false;
            }

            return;
        }

        // Fill config dialog with newsletter data
        GetNewsletterValues(newsletterObj);

        if (!isDynamic)
        {
            issueTemplate.Value = newsletterObj.NewsletterTemplateID.ToString();
            return;
        }

        // Check if dynamic newsletter subject is empty
        bool subjectEmpty = string.IsNullOrEmpty(newsletterObj.NewsletterDynamicSubject);

        radPageTitle.Checked = subjectEmpty;
        radFollowing.Checked = !subjectEmpty;
        radPageTitle_CheckedChanged(null, null);
        if (!subjectEmpty)
        {
            txtSubject.Text = newsletterObj.NewsletterDynamicSubject;
        }

        txtNewsletterDynamicURL.Text = newsletterObj.NewsletterDynamicURL;

        TaskInfo task = TaskInfoProvider.GetTaskInfo(newsletterObj.NewsletterDynamicScheduledTaskID);

        if (task != null)
        {
            chkSchedule.Checked = plcInterval.Visible = true;
            schedulerInterval.ScheduleInterval = task.TaskInterval;
        }
        else
        {
            chkSchedule.Checked       = false;
            schedulerInterval.Visible = false;
        }
    }
 private static TaskInfo CreateDynamicNewsletterTask(Newsletter newsletterObj)
 {
     return new TaskInfo()
     {
         TaskAssemblyName = "CMS.Newsletter",
         TaskClass = "CMS.Newsletter.DynamicNewsletterSender",
         TaskEnabled = true,
         TaskLastResult = string.Empty,
         TaskSiteID = CMSContext.CurrentSiteID,
         TaskData = newsletterObj.NewsletterGUID.ToString()
     };
 }
    protected void btnRegister_Click(object sender, EventArgs e)
    {
        if (IsValid)
        {
            var oAddressBook = new AddressBook();
            var FirstName = txtFullName.Text.Trim();
            var LastName = "";
            var Email = txtEmailRegister.Text.Trim();
            var HomePhone = txtPhone.Text.Trim();
            var CellPhone = "";
            var Fax = "";
            //var ReceiveEmail = chkNewLetter.Checked.ToString();
            //var ReceiveEmail = "";
            var UserName = txtEmailRegister.Text.Trim();
            var Password = txtPasswordRegister.Text.Trim();
            var Company = "";
            var Address1 = txtAddress.Text.Trim();
            var Address2 = "";
            var ZipCode = "";
            //var City = txtCity.Text.Trim();
            var City = "";
            var CountryID = "1";
            var ProvinceID = ddlProvince.SelectedValue;
            var DistrictID = ddlDistrict.SelectedValue;
            var IsPrimary = "True";
            var IsPrimaryBilling = "True";
            var IsPrimaryShipping = "True";
            var RoleName = "customer";
            //var Gender = rdbGender.SelectedValue;
            DateTime strDateOfBirth = new DateTime(Convert.ToInt32(ddlYear.SelectedItem.Text),
                Convert.ToInt32(ddlMonth.SelectedItem.Text), Convert.ToInt32(ddlDay.SelectedItem.Text));
            string Birthday = strDateOfBirth.ToString("MM/dd/yyyy");
            bool bError = false;
            if (!string.IsNullOrEmpty(UserName))
            {
                if (Membership.GetUser(UserName) != null)
                {
                    CustomValidator2.ErrorMessage = "<b>+ Tên truy cập " + UserName +
                                                    " đã được đăng ký sử dụng, vui lòng chọn tên khác</b>";
                    CustomValidator2.IsValid = false;
                    bError = true;
                }
                else
                    CustomValidator2.IsValid = true;
            }
            if (!bError)
            {
                Membership.CreateUser(UserName, Password, Email);
                Roles.AddUserToRole(UserName, RoleName);
                //var oUser = new User();
                //oUser.UserInsert(UserName, Password, Email, Role);
                oAddressBook.AddressBookInsert1(
                    FirstName,
                    LastName,
                    Email,
                    HomePhone,
                    CellPhone,
                    Fax,
                    //ReceiveEmail,
                    UserName,
                    Company,
                    Address1,
                    Address2,
                    ZipCode,
                    City,
                    CountryID,
                    ProvinceID,
                    DistrictID,
                    IsPrimary,
                    IsPrimaryBilling,
                    IsPrimaryShipping,
                    RoleName,
                    "",
                    Birthday
                    );
                if (ckbNewsletter.Checked)
                {
                    var oNewletter = new Newsletter();
                    oNewletter.NewsletterInsert(Email);
                }
                FormsAuthentication.SetAuthCookie(UserName, true);
                //pnlSuccess.Visible = true;
                Session["UserName"] = UserName;
                ////var CC = "*****@*****.**";
                //var Subject = "Đăng ký tài khoản thành công/Thanks for Registering";
                ////var OrderCode = OrderID;
                //string Host = "118.69.199.203";
                //int Port = 25;
                //string From = "*****@*****.**";
                //string mPassword = "******";
                //string Body = "<div style='width: 100%; font-size: 11px; font-family: Arial;'>";
                //Body += "<h3 style='color: rgb(204,102,0); font-size: 22px; border-bottom-color: gray; border-bottom-width: 1px;border-bottom-style: dashed; margin-bottom: 20px; font-family: Times New Roman;'>";
                //Body += "Cảm ơn bạn đã đăng ký tài khoản/Thanks for Registering";
                //Body += "</h3>";
                //Body += "<div style='font-family: Verdana; font-size: 11px; margin-bottom: 20px;'>";
                //Body += "<p>Xin chào " + FirstName + "/Hi " + FirstName + ",</p>";
                //Body += "<p>Cảm ơn bạn đã đăng ký tài khoản tại EZStore/ Many thanks for registering at EZStore</p>";
                //Body += "<p>Thông tin đăng nhập của bạn như sau/ Your login detail is as follow:</p>";
                //Body += "<p>Email: <b>" + Email + "</b></p>";
                //Body += "<p>Mật khẩu/Password: <b>" + Password + "</b></p>";
                //Body += "<p>Mọi thắc mắc, xin vui lòng liên hệ với chúng tôi qua email: <a href='mailto:[email protected]'>[email protected]</a> /If you have any enquiries, please email us on <a href='mailto:[email protected]'>[email protected]</a></p>";
                //Body += "<p>Chúc bạn có những thời khắc ngọt ngào với EZStore/ We hope you have great expericences with EZStore</p>";
                //Body += "</div>";
                //Body += "<div style='font-family:Verdana;font-size:12px;margin-top:10px;'>";
                //Body += "<div style='font-size:16px;font-weight:bold;'>=================</div>";
                //Body += "<h4 style='font-size:14px;font-family:Verdana;margin:0;padding:0;'>EZStore</h4>";
                //Body += "<div style='font-size:11px;font-family:Verdana;margin-top:5px;padding:0;margin:0;'>";
                //Body += "<p>Add: 403, Hai Bà Trưng , P.8, Quận 3, HCM</p>";
                //Body += "<p>Tel: (08)3 820 8577 - Hotline: 0902 563 577</p>";
                ////Body += "<p>M: +84 908 xxx xxx>";

                //Body += "<p>W: <a href='http://www.pandemos.vn'>www.pandemos.vn</a></p>";
                //Body += "<p>E: <a href='mailto:[email protected]'>[email protected]</a></p>";
                //Body += "</div>";
                //Body += "</div>";
                //Body += "</div>";
                //Common.SendMail(Host, Port, From, mPassword, Email, "", Subject, Body, false);

                //txtUserNameRegister.Text =
                txtAddress.Text =
                    txtEmailRegister.Text =
                        txtFullName.Text =
                            txtPasswordRegister.Text =
                    //txtVerifyCode.Text =
                                txtConfirmPassWordRegister.Text = "";
                ddlYear.SelectedIndex = ddlDay.SelectedIndex = ddlMonth.SelectedIndex = -1;
                lblEmailMessage.Text = "";
                ckbSuccess.Checked = false;
                ckbNewsletter.Checked = false;
                //ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "runtime", "alert('Bạn đã đăng ký thành công!')", true);
                Response.Redirect("~/dang-ky-dang-nhap.aspx");
            }
        }
    }
Beispiel #34
0
 private bool CheckIfActive(Newsletter page)
 {
     return(page.IsActive);
 }
Beispiel #35
0
    /// <summary>
    /// Creates static newsletter. Called when the "Create newsletter" button is pressed.
    /// </summary>
    private bool CreateStaticNewsletter()
    {
        EmailTemplate subscriptionTemplate = EmailTemplateProvider.GetEmailTemplate("MyNewSubscriptionTemplate", CMSContext.CurrentSiteID);
        EmailTemplate unsubscriptionTemplate = EmailTemplateProvider.GetEmailTemplate("MyNewUnsubscriptionTemplate", CMSContext.CurrentSiteID);
        EmailTemplate myNewIssueTemplate = EmailTemplateProvider.GetEmailTemplate("MyNewIssueTemplate", CMSContext.CurrentSiteID);

        if ((subscriptionTemplate != null) && (unsubscriptionTemplate != null) && (myNewIssueTemplate != null))
        {
            // Create new static newsletter object
            Newsletter newNewsletter = new Newsletter();

            // Set the properties
            newNewsletter.NewsletterDisplayName = "My new static newsletter";
            newNewsletter.NewsletterName = "MyNewStaticNewsletter";
            newNewsletter.NewsletterType = NewsletterType.TemplateBased;
            newNewsletter.NewsletterSubscriptionTemplateID = subscriptionTemplate.TemplateID;
            newNewsletter.NewsletterUnsubscriptionTemplateID = unsubscriptionTemplate.TemplateID;
            newNewsletter.NewsletterTemplateID = myNewIssueTemplate.TemplateID;
            newNewsletter.NewsletterSenderName = "Sender name";
            newNewsletter.NewsletterSenderEmail = "*****@*****.**";
            newNewsletter.NewsletterSiteID = CMSContext.CurrentSiteID;

            // Save the static newsletter
            NewsletterProvider.SetNewsletter(newNewsletter);

            return true;
        }

        return false;
    }
        public async Task <ActionResult> send_new_entry(Newsletter newsletter) // send_new_entry
        {
            token = db.People.Find(0).last_name;                               // secret token fetch from DB
            discord.start(token);
            ViewData["value"] = newsletter.newest_message + "\nmessage sent!";
            //ViewBag.Message = newsletter.content + "\nmessage sent!";
            int id = Int32.Parse(Session["UserID"].ToString());

            newsletter.fk_Personid_Person = id;

            // 1. update the approriate sub's content with the newest one.
            int newsletter_id = newsletter.update();

            subs.fk_Newsletterid_Newsletter = newsletter_id;

            // 2. select all subed_newsletter who sub'd to this newsletter
            List <Subscription> subs_temp = subs.select_subscribers();

            int    count = subs_temp.Count();
            string str1  = "";

            if (id >= 0)
            {
                str1 = "Successfully sent your message! Total subs receiving this message: " + count;
            }
            else
            {
                str1            = "Message send failed!";
                ViewBag.Message = str1;
                return(View("NewsletterForm"));
            }

            if (newsletter.newest_message == "" || newsletter.newest_message == null)
            {
                str1            = "Only non-empty messages may be sent!";
                ViewBag.Message = str1;
                return(View("NewsletterForm"));
            }

            // 3. select receit forms from users
            List <string> receit_forms = person.select_receit_forms(subs_temp);


            // 3. generate newsletter_entries
            int message_count = entries.insert(newsletter, subs_temp, receit_forms);



            // 4. reselect all the entries that are not sent out yet
            List <Newsletter_entry> entries_to_send = entries.select(newsletter_id);
            int total = entries_to_send.Count();

            str1           += "\n Total getting sent out: " + total;
            bool[,] replies = new bool[total, 2];
            // 5. initiate the sending sequence below

            for (int i = 0; i < total; i++)
            {
                var rep1    = false;
                var rep2    = false;
                var thread1 = new Thread(() =>
                {
                    rep1 = send_discord(entries_to_send[i], newsletter.newest_message);
                });

                var thread2 = new Thread(() =>
                {
                    rep2 = send_email(entries_to_send[i], newsletter.newest_message);
                });
                thread1.Start();
                thread2.Start();
                thread1.Join();
                thread2.Join();
                replies[i, 0] = rep1;
                replies[i, 1] = rep2;
                Console.Write("hi");
            }

            ViewBag.Message = str1;
            return(View("NewsletterForm"));
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        // If StopProcessing flag is set, do nothing
        if (StopProcessing)
        {
            Visible = false;
            return;
        }

        string subscriptionHash = QueryHelper.GetString("subscriptionhash", string.Empty);
        string requestTime      = QueryHelper.GetString("datetime", string.Empty);

        DateTime datetime = DateTimeHelper.ZERO_TIME;

        // Get date and time
        if (!string.IsNullOrEmpty(requestTime))
        {
            try
            {
                datetime = DateTime.ParseExact(requestTime, SecurityHelper.EMAIL_CONFIRMATION_DATETIME_FORMAT, null);
            }
            catch
            {
                lblInfo.Text = ResHelper.GetString("newsletter.approval_failed");
                return;
            }
        }

        if (string.IsNullOrEmpty(subscriptionHash))
        {
            this.Visible = false;
            return;
        }

        // Try to approve subscription
        SubscriberProvider.ApprovalResult result = SubscriberProvider.ApproveSubscription(subscriptionHash, false, CMSContext.CurrentSiteName, datetime);

        switch (result)
        {
        // Approving subscription was successful
        case SubscriberProvider.ApprovalResult.Success:
            if (!String.IsNullOrEmpty(this.SuccessfulApprovalText))
            {
                lblInfo.Text = this.SuccessfulApprovalText;
            }
            else
            {
                lblInfo.Text = ResHelper.GetString("newsletter.successful_approval");
            }

            // Log newsletter subscription activity
            if ((CMSContext.ViewMode == ViewModeEnum.LiveSite))
            {
                SubscriberNewsletterInfo sni = SubscriberNewsletterInfoProvider.GetSubscriberNewsletterInfo(subscriptionHash);
                if (sni != null)
                {
                    // Load subscriber info and make sure activity modul is enabled
                    Subscriber sb = SubscriberProvider.GetSubscriber(sni.SubscriberID);
                    if ((sb != null) && ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(sb.SubscriberSiteID))
                    {
                        int        siteId = sb.SubscriberSiteID;
                        Newsletter news   = NewsletterProvider.GetNewsletter(sni.NewsletterID);
                        if (news.NewsletterLogActivity && ActivitySettingsHelper.NewsletterSubscribeEnabled(siteId))
                        {
                            // Under what contacs this subscriber belogs to?
                            int contactId = ActivityTrackingHelper.GetContactID(sb);

                            if (contactId > 0)
                            {
                                ModuleCommands.OnlineMarketingUpdateContactFromExternalData(sb, contactId);
                                ModuleCommands.OnlineMarketingCreateRelation(sb.SubscriberID, MembershipType.NEWSLETTER_SUBSCRIBER, contactId);
                                var data = new ActivityData()
                                {
                                    ContactID = contactId,
                                    SiteID    = sb.SubscriberSiteID,
                                    Type      = PredefinedActivityType.NEWSLETTER_SUBSCRIBING,
                                    TitleData = news.NewsletterName,
                                    ItemID    = news.NewsletterID,
                                    URL       = URLHelper.CurrentRelativePath,
                                    Campaign  = CMSContext.Campaign
                                };
                                ActivityLogProvider.LogActivity(data);
                            }
                        }
                    }
                }
            }
            break;

        // Subscription was already approved
        case SubscriberProvider.ApprovalResult.Failed:
            if (!String.IsNullOrEmpty(this.UnsuccessfulApprovalText))
            {
                lblInfo.Text = this.UnsuccessfulApprovalText;
            }
            else
            {
                lblInfo.Text = ResHelper.GetString("newsletter.approval_failed");
            }
            break;

        case SubscriberProvider.ApprovalResult.TimeExceeded:
            if (!String.IsNullOrEmpty(this.UnsuccessfulApprovalText))
            {
                lblInfo.Text = this.UnsuccessfulApprovalText;
            }
            else
            {
                lblInfo.Text = ResHelper.GetString("newsletter.approval_timeexceeded");
            }
            break;


        // Subscription not found
        default:
        case SubscriberProvider.ApprovalResult.NotFound:
            if (!String.IsNullOrEmpty(this.UnsuccessfulApprovalText))
            {
                lblInfo.Text = this.UnsuccessfulApprovalText;
            }
            else
            {
                lblInfo.Text = ResHelper.GetString("newsletter.approval_invalid");
            }
            break;
        }
    }
        public ActionResult FacebookAjx(string token)
        {
            try
            {
                if (!string.IsNullOrEmpty(token))
                {
                    WebClient client     = new WebClient();
                    string    JsonResult = client.DownloadString(string.Concat(
                                                                     "https://graph.facebook.com/me?access_token=", token));

                    JObject jsonUserInfo = JObject.Parse(JsonResult);

                    FacebookProfile fp = new FacebookProfile();
                    fp.FacebookUsername = jsonUserInfo.Value <string>("username");
                    fp.FacebookEmail    = jsonUserInfo.Value <string>("email");
                    fp.FacebookLocale   = jsonUserInfo.Value <string>("locale");
                    fp.FacebookID       = jsonUserInfo.Value <long>("id");
                    fp.FacebookToken    = token;

                    fp.FacebookName        = jsonUserInfo.Value <string>("name");
                    fp.FacebookFirstName   = jsonUserInfo.Value <string>("first_name");
                    fp.FacebookLastName    = jsonUserInfo.Value <string>("last_name");
                    fp.FacebookLink        = jsonUserInfo.Value <string>("link");
                    fp.FacebookGender      = jsonUserInfo.Value <string>("gender");
                    fp.FacebookTimezone    = jsonUserInfo.Value <int>("timezone");
                    fp.FacebookVerified    = jsonUserInfo.Value <bool>("verified");
                    fp.FacebookUpdatedTime = jsonUserInfo.Value <DateTime>("updated_time");

                    User uLogin = _db.Users.FirstOrDefault(r => r.FacebookID == fp.FacebookID);
                    if (uLogin != null)
                    {
                        //login
                        LS.Authorize(uLogin);
                        // var messService = new MessageService(_db);
                        // messService.SendUserRegisterEmailToUser(u);
                        return(Json(new { result = "ok", url = "" }));
                    }
                    else
                    {
                        //register
                        string email = fp.FacebookEmail;
                        //generate code
                        var chars    = "0123456789abcdefghjklmnopqrstuwvxyzQAZWSXEDCRFVTGBYHNUJMIKLOP@$&%";
                        var random   = new Random();
                        var password = new string(
                            Enumerable.Repeat(chars, 8)
                            .Select(s => s[random.Next(s.Length)])
                            .ToArray());
                        if (string.IsNullOrEmpty(email))
                        {
                            if (!string.IsNullOrEmpty(fp.FacebookUsername))
                            {
                                email = fp.FacebookUsername + "@facebook.com";
                            }
                            else
                            {
                                email = fp.FacebookID.ToString() + "@facebook.com";
                            }
                        }
                        User uExist = _db.Users.FirstOrDefault(r => r.UserName == email);
                        if (uExist != null)
                        {
                            uExist.FacebookID = fp.FacebookID;
                            _db.SaveChanges();//update facebook ID
                            //login
                            LS.Authorize(uExist);

                            return(Json(new { result = "ok", url = "" }));
                        }
                        MembershipCreateStatus createStatus;
                        MembershipUser         newUser = Membership.CreateUser(email, password, email, "-", "-", true, out createStatus);

                        if (createStatus != MembershipCreateStatus.Success)
                        {
                            ModelState.AddModelError(string.Empty, RP.T("Account.Register.Error." + createStatus.ToString()).ToString());
                        }
                        else
                        {
                            User u = _db.Users.FirstOrDefault(r => r.UserName == email);
                            u.Roles            = SF.RolesStringAdd(u.Roles, "Register");
                            u.FirstName        = fp.FacebookFirstName;
                            u.LastName         = fp.FacebookLastName;
                            u.RoleDefault      = "Register";
                            u.FacebookID       = fp.FacebookID;
                            u.IsApproved       = true;
                            _db.Entry(u).State = EntityState.Modified;
                            _db.SaveChanges();

                            Newsletter n = new Newsletter()
                            {
                                NewsletterAccept = true,
                                NewsletterDate   = DateTime.UtcNow,
                                NewsletterEmail  = u.Email,
                                NewsletterName   = u.FirstName + " " + u.LastName,
                                RoleDefault      = "Register"
                            };
                            _db.Newsletters.Add(n);
                            _db.SaveChanges();
                            SF.AddToNewsletter(n);

                            if (Membership.ValidateUser(u.UserName, u.Password))
                            {
                                LS.Authorize(u);
                                var messService = new MessageService(_db);

                                messService.SendUserRegisterEmailToUser(u);
                                return(Json(new { result = "ok", url = "" }));
                            }
                            else
                            {
                                ModelState.AddModelError("", RP.T("Account.Logon.PasswordOrUserIncorrect").ToString());
                            }
                        }
                    }
                    return(Json(new { result = "error", json = JsonResult, facebook = fp, message = ModelState.Values.Select(x => new { Value = x.Value != null ? x.Value.AttemptedValue : "", errors = x.Errors.Select(y => y.ErrorMessage) }) }));
                }
                return(Json(new { result = "error", message = ModelState.Values.Select(x => new { Value = x.Value != null ? x.Value.AttemptedValue : "", errors = x.Errors.Select(y => y.ErrorMessage) }) }));
            }
            catch (Exception error)
            {
                SF.LogError(error);
                return(Json(new { result = "error", message = error.Message }));
            }
        }
Beispiel #39
0
    /// <summary>
    /// Creates dynamic newsletter. Called when the "Create newsletter" button is pressed.
    /// </summary>
    private bool CreateDynamicNewsletter()
    {
        EmailTemplate subscriptionTemplate = EmailTemplateProvider.GetEmailTemplate("MyNewSubscriptionTemplate", CMSContext.CurrentSiteID);
        EmailTemplate unsubscriptionTemplate = EmailTemplateProvider.GetEmailTemplate("MyNewUnsubscriptionTemplate", CMSContext.CurrentSiteID);

        if ((subscriptionTemplate != null) && (unsubscriptionTemplate != null))
        {
            // Create new dynamic newsletter object
            Newsletter newNewsletter = new Newsletter();

            // Set the properties
            newNewsletter.NewsletterDisplayName = "My new dynamic newsletter";
            newNewsletter.NewsletterName = "MyNewDynamicNewsletter";
            newNewsletter.NewsletterType = NewsletterType.Dynamic;
            newNewsletter.NewsletterSubscriptionTemplateID = subscriptionTemplate.TemplateID;
            newNewsletter.NewsletterUnsubscriptionTemplateID = unsubscriptionTemplate.TemplateID;
            newNewsletter.NewsletterSenderName = "Sender name";
            newNewsletter.NewsletterSenderEmail = "*****@*****.**";
            newNewsletter.NewsletterDynamicURL = "http://www.google.com";
            newNewsletter.NewsletterDynamicSubject = "My new dynamic issue";
            newNewsletter.NewsletterSiteID = CMSContext.CurrentSiteID;

            // Save the dynamic newsletter
            NewsletterProvider.SetNewsletter(newNewsletter);

            return true;
        }

        return false;
    }
        public ActionResult GoogleAjx(string ID, string Name, string Image, string Email)
        {
            // google 111929910329405075066
            // long   9223372036854775807
            if (!string.IsNullOrEmpty(ID) && ID != "0")
            {
                string email = Email;
                if (string.IsNullOrEmpty(email))
                {
                    email = ID + "@gmail.com.com";
                }


                User uLogin = _db.Users.FirstOrDefault(r => r.GoogleID == ID);
                if (uLogin != null)
                {
                    //login
                    LS.Authorize(uLogin);
                    // var messService = new MessageService(_db);
                    // messService.SendUserRegisterEmailToUser(u);
                    return(Json(new { result = "ok", url = "" }));
                }
                else
                {
                    //register

                    //generate code
                    var chars    = "0123456789abcdefghjklmnopqrstuwvxyzQAZWSXEDCRFVTGBYHNUJMIKLOP@$&%";
                    var random   = new Random();
                    var password = new string(
                        Enumerable.Repeat(chars, 8)
                        .Select(s => s[random.Next(s.Length)])
                        .ToArray());

                    User uExist = _db.Users.FirstOrDefault(r => r.UserName == email || r.Email == email);
                    if (uExist != null)
                    {
                        uExist.GoogleID = ID;

                        _db.SaveChanges();//update facebook ID
                        //login
                        LS.Authorize(uExist);

                        return(Json(new { result = "ok", url = "" }));
                    }
                    MembershipCreateStatus createStatus;
                    MembershipUser         newUser = Membership.CreateUser(email, password, email, "-", "-", true, out createStatus);

                    if (createStatus != MembershipCreateStatus.Success)
                    {
                        ModelState.AddModelError(string.Empty, RP.T("Account.Register.Error." + createStatus.ToString()).ToString());
                    }
                    else
                    {
                        User u = _db.Users.FirstOrDefault(r => r.UserName == email);
                        u.Roles     = SF.RolesStringAdd(u.Roles, "Register");
                        u.FirstName = "";
                        u.LastName  = "";
                        if (!string.IsNullOrEmpty(Name))
                        {
                            string[] firstLast = Name.Split(new char[] { ' ' }, 2, StringSplitOptions.RemoveEmptyEntries);
                            if (firstLast.Length > 0)
                            {
                                u.FirstName = firstLast[0];
                            }
                            if (firstLast.Length > 1)
                            {
                                u.LastName = firstLast[1];
                            }
                        }
                        u.RoleDefault      = "Register";
                        u.GoogleID         = ID;
                        u.IsApproved       = true;
                        _db.Entry(u).State = EntityState.Modified;
                        _db.SaveChanges();

                        Newsletter n = new Newsletter()
                        {
                            NewsletterAccept = true,
                            NewsletterDate   = DateTime.UtcNow,
                            NewsletterEmail  = u.Email,
                            NewsletterName   = u.FirstName + " " + u.LastName,
                            RoleDefault      = "Register"
                        };
                        _db.Newsletters.Add(n);
                        _db.SaveChanges();
                        SF.AddToNewsletter(n);


                        if (Membership.ValidateUser(u.UserName, u.Password))
                        {
                            LS.Authorize(u);

                            var messService = new MessageService(_db);
                            messService.SendUserRegisterEmailToUser(u);
                            return(Json(new { result = "ok", url = "" }));
                        }
                        else
                        {
                            ModelState.AddModelError("", RP.T("Account.Logon.PasswordOrUserIncorrect").ToString());
                        }
                    }
                }
                return(Json(new { result = "error", message = ModelState.Values.Select(x => new { Value = x.Value != null ? x.Value.AttemptedValue : "", errors = x.Errors.Select(y => y.ErrorMessage) }) }));
            }
            return(Json(new { result = "error", message = ModelState.Values.Select(x => new { Value = x.Value != null ? x.Value.AttemptedValue : "", errors = x.Errors.Select(y => y.ErrorMessage) }) }));
        }
    private void GetNewsletterValues(Newsletter newsletter)
    {
        txtNewsletterDisplayName.Text = newsletter.NewsletterDisplayName;
        txtNewsletterName.Text = newsletter.NewsletterName;
        txtNewsletterSenderName.Text = newsletter.NewsletterSenderName;
        txtNewsletterSenderEmail.Text = newsletter.NewsletterSenderEmail;
        txtNewsletterBaseUrl.Text = newsletter.NewsletterBaseUrl;
        txtNewsletterUnsubscribeUrl.Text = newsletter.NewsletterUnsubscribeUrl;
        txtDraftEmails.Text = newsletter.NewsletterDraftEmails;
        chkUseEmailQueue.Checked = newsletter.NewsletterUseEmailQueue;

        subscriptionTemplate.Value = newsletter.NewsletterSubscriptionTemplateID.ToString();
        unsubscriptionTemplate.Value = newsletter.NewsletterUnsubscriptionTemplateID.ToString();

        plcOnlineMarketing.Visible = onlineMarketingEnabled;
        chkTrackOpenedEmails.Checked = newsletter.NewsletterTrackOpenEmails;
        chkTrackClickedLinks.Checked = newsletter.NewsletterTrackClickedLinks;
        chkLogActivity.Checked = newsletter.NewsletterLogActivity;

        chkEnableOptIn.Checked = newsletter.NewsletterEnableOptIn;
        optInSelector.Value = newsletter.NewsletterOptInTemplateID;
        txtOptInURL.Text = newsletter.NewsletterOptInApprovalURL;
        chkSendOptInConfirmation.Checked = newsletter.NewsletterSendOptInConfirmation;
    }
 public void Update(Newsletter entity)
 {
     _newsletterRepository.Update(entity);
 }
Beispiel #43
0
    } // End of the Add method

    #endregion

    #region Update methods

    /// <summary>
    /// Update a newsletter post
    /// </summary>
    /// <param name="post">A reference to a newsletter post</param>
    public static void Update(Newsletter post)
    {
        // Create the connection and the sql statement
        string connection = Tools.GetConnectionString();
        string sql = "UPDATE dbo.newsletters SET language_id = @language_id, title = @title, "
            + "content = @content, sent_date = @sent_date WHERE id = @id;";

        // The using block is used to call dispose automatically even if there are an exception.
        using (SqlConnection cn = new SqlConnection(connection))
        {
            // The using block is used to call dispose automatically even if there are an exception.
            using (SqlCommand cmd = new SqlCommand(sql, cn))
            {
                // Add parameters
                cmd.Parameters.AddWithValue("@id", post.id);
                cmd.Parameters.AddWithValue("@language_id", post.language_id);
                cmd.Parameters.AddWithValue("@title", post.title);
                cmd.Parameters.AddWithValue("@content", post.content);
                cmd.Parameters.AddWithValue("@sent_date", post.sent_date);

                // The Try/Catch/Finally statement is used to handle unusual exceptions in the code to
                // avoid having our application crash in such cases.
                try
                {
                    // Open the connection.
                    cn.Open();

                    // Execute the update
                    cmd.ExecuteNonQuery();

                }
                catch (Exception e)
                {
                    throw e;
                }
            }
        }

    } // End of the Update method
Beispiel #44
0
 public void Create(Newsletter newsletter)
 {
     _context.Newsletter.Add(newsletter);
     _context.SaveChanges();
 }
Beispiel #45
0
    /// <summary>
    /// Gets and bulk updates static newsletters. Called when the "Get and bulk update newsletters" button is pressed.
    /// Expects the CreateStaticNewsletter method to be run first.
    /// </summary>
    private bool GetAndBulkUpdateStaticNewsletters()
    {
        // Prepare the parameters
        string where = "NewsletterName LIKE N'MyNewStaticNewsletter%'";

        // Get the data
        DataSet newsletters = NewsletterProvider.GetNewsletters(where, null, 0, null);
        if (!DataHelper.DataSourceIsEmpty(newsletters))
        {
            // Loop through the individual items
            foreach (DataRow newsletterDr in newsletters.Tables[0].Rows)
            {
                // Create object from DataRow
                Newsletter modifyNewsletter = new Newsletter(newsletterDr);

                // Update the properties
                modifyNewsletter.NewsletterDisplayName = modifyNewsletter.NewsletterDisplayName.ToUpper();

                // Save the changes
                NewsletterProvider.SetNewsletter(modifyNewsletter);
            }

            return true;
        }

        return false;
    }
Beispiel #46
0
 public void Update(Newsletter newsletter)
 {
     _context.Entry(newsletter).State = EntityState.Modified;
     _context.SaveChanges();
 }
Beispiel #47
0
        /// <summary>
        ///A test for Update
        ///</summary>
        //[TestMethod()]
        public void UpdateTest()
        {
            NewsletterDAL target = new NewsletterDAL();
            Newsletter newsletter = new Newsletter();

            newsletter.IdNewsletter = 1;
            newsletter.Email = "*****@*****.**";
            newsletter.Data = DateTime.Now;
            

            target.Update(newsletter);
            Newsletter newsletterTest = target.Obter("IdNewsletter = " + newsletter.IdNewsletter);

            Assert.AreEqual(newsletter.IdNewsletter, newsletterTest.IdNewsletter);
            Assert.AreEqual(newsletter.Email, newsletterTest.Email);
            Assert.AreEqual(newsletter.Data, newsletterTest.Data);
        }
Beispiel #48
0
 public void Delete(Newsletter newsletter)
 {
     newsletter.IsDeleted = true;
     Update(newsletter);
 }
    /// <summary>
    /// Sets data to database.
    /// </summary>
    protected void btnOK_Click(object sender, EventArgs e)
    {
        // Check 'configure' permission
        if (!CMSContext.CurrentUser.IsAuthorizedPerResource("cms.newsletter", "configure"))
        {
            RedirectToCMSDeskAccessDenied("cms.newsletter", "configure");
        }

        // Validate base inputs (newsletter display name, code name, sender name, sender e-mail)
        string errorMessage = new Validator().NotEmpty(txtNewsletterDisplayName.Text.Trim(), GetString("general.requiresdisplayname")).NotEmpty(txtNewsletterName.Text.Trim(), GetString("Newsletter_Edit.ErrorEmptyName")).NotEmpty(txtNewsletterSenderName.Text.Trim(), GetString("Newsletter_Edit.ErrorEmptySenderName")).NotEmpty(txtNewsletterSenderEmail.Text.Trim(), GetString("Newsletter_Edit.ErrorEmptySenderEmail")).IsEmail(txtNewsletterSenderEmail.Text.Trim(), GetString("Newsletter_Edit.ErrorEmailFormat")).IsCodeName(txtNewsletterName.Text.Trim(), GetString("general.invalidcodename")).Result;

        if (String.IsNullOrEmpty(errorMessage))
        {
            if (String.IsNullOrEmpty((string)subscriptionTemplate.Value))
            {
                // No subscription template selected
                lblSubscriptionError.Visible = true;
                return;
            }

            if (String.IsNullOrEmpty((string)unsubscriptionTemplate.Value))
            {
                // No unsubscription template selected
                lblUnsubscriptionError.Visible = true;
                return;
            }

            if ((radTemplateBased.Checked) && (String.IsNullOrEmpty((string)issueTemplate.Value)))
            {
                // No issue template selected for template based newsletter
                lblIssueError.Visible = true;
                return;
            }

            if ((radDynamic.Checked) && (!ScheduleInterval.CheckOneDayMinimum()))
            {
                // Problem occurred while setting schedule interval for dynamic newsletter
                lblError.Visible = true;
                lblError.Text    = GetString("Newsletter_Edit.NoDaySelected");
                return;
            }

            // Newsletter code name must to be unique per site...
            Newsletter newsletterObj = NewsletterProvider.GetNewsletter(txtNewsletterName.Text.Trim(), CMSContext.CurrentSiteID);

            // If newsletter code name is unique...
            if (newsletterObj == null)
            {
                // Create new item -> insert
                newsletterObj = new Newsletter();

                newsletterObj.NewsletterDisplayName = txtNewsletterDisplayName.Text.Trim();
                newsletterObj.NewsletterName        = txtNewsletterName.Text.Trim();

                int selectedValue = ValidationHelper.GetInteger(subscriptionTemplate.Value, 0);
                if (selectedValue != 0)
                {
                    newsletterObj.NewsletterSubscriptionTemplateID = selectedValue;
                }
                else
                {
                    lblError.Visible = true;
                    lblError.Text    = GetString("Newsletter_Edit.NoSubscriptionTemplateSelected");
                    return;
                }

                selectedValue = ValidationHelper.GetInteger(unsubscriptionTemplate.Value, 0);
                if (selectedValue != 0)
                {
                    newsletterObj.NewsletterUnsubscriptionTemplateID = selectedValue;
                }
                else
                {
                    lblError.Visible = true;
                    lblError.Text    = GetString("Newsletter_Edit.NoUnsubscriptionTemplateSelected");
                    return;
                }
                newsletterObj.NewsletterSenderName  = txtNewsletterSenderName.Text.Trim();
                newsletterObj.NewsletterSenderEmail = txtNewsletterSenderEmail.Text.Trim();
                if (radDynamic.Checked)
                {
                    newsletterObj.NewsletterDynamicURL = txtNewsletterDynamicURL.Text.Trim();
                    newsletterObj.NewsletterType       = NewsletterType.Dynamic;
                }
                else
                {
                    selectedValue = ValidationHelper.GetInteger(issueTemplate.Value, 0);
                    if (selectedValue != 0)
                    {
                        newsletterObj.NewsletterTemplateID = selectedValue;
                    }
                    else
                    {
                        lblError.Visible = true;
                        lblError.Text    = GetString("Newsletter_Edit.NoEmailTemplateSelected");
                        return;
                    }
                    newsletterObj.NewsletterType = NewsletterType.TemplateBased;
                }
                newsletterObj.NewsletterSiteID      = CMSContext.CurrentSiteID;
                newsletterObj.NewsletterGUID        = Guid.NewGuid();
                newsletterObj.NewsletterLogActivity = true;

                if (NewsletterProvider.LicenseVersionCheck(URLHelper.GetCurrentDomain(), FeatureEnum.Newsletters, VersionActionEnum.Insert))
                {
                    // Create new newsletter
                    NewsletterProvider.SetNewsletter(newsletterObj);

                    if (radDynamic.Checked)
                    {
                        if (chkSchedule.Checked)
                        {
                            // Create new task to schedule the dynamic newsletter
                            TaskInfo task = new TaskInfo();
                            task.TaskAssemblyName = "CMS.Newsletter";
                            task.TaskClass        = "CMS.Newsletter.DynamicNewsletterSender";
                            task.TaskDisplayName  = GetString("DynamicNewsletter.TaskName") + newsletterObj.NewsletterDisplayName;
                            task.TaskEnabled      = true;
                            task.TaskInterval     = ScheduleInterval.ScheduleInterval;
                            task.TaskLastResult   = string.Empty;
                            task.TaskName         = "DynamicNewsletter." + ValidationHelper.GetCodeName(newsletterObj.NewsletterName, "_");
                            task.TaskSiteID       = CMSContext.CurrentSiteID;
                            task.TaskNextRunTime  = SchedulingHelper.GetNextTime(task.TaskInterval, new DateTime(), new DateTime());
                            task.TaskData         = newsletterObj.NewsletterGUID.ToString();
                            // Set task for processing in external service
                            task.TaskAllowExternalService = true;
                            task.TaskUseExternalService   = (SchedulingHelper.UseExternalService && NewsletterProvider.UseExternalServiceForDynamicNewsletters(CMSContext.CurrentSiteName));

                            TaskInfoProvider.SetTaskInfo(task);

                            newsletterObj.NewsletterDynamicScheduledTaskID = task.TaskID;
                            NewsletterProvider.SetNewsletter(newsletterObj);
                        }
                    }
                    URLHelper.Redirect("Newsletter_Frameset.aspx?newsletterid=" + ValidationHelper.GetString(newsletterObj.NewsletterID, null) + "&saved=1");
                }
                else
                {
                    lblError.Visible = true;
                    lblError.Text    = GetString("LicenseVersionCheck.Newsletter");
                }
            }
            else
            {
                lblError.Visible = true;
                lblError.Text    = GetString("Newsletter_Edit.NewsletterNameExists");
            }
        }
        else
        {
            lblError.Visible = true;
            lblError.Text    = errorMessage;
        }
    }
Beispiel #50
0
    public string Get_Newsletter_P(string token)
    {
        if (!CheckToken(token))
        {
            return("Erreur de Token");
        }
        else
        {
            try
            {
                StringBuilder sb = new StringBuilder();

                Newsletter n = DataMapping.GetNewsletter_By_status("P");

                if (n != null)
                {
                    if (!string.IsNullOrEmpty(n.recipient))
                    {
                        List <Member> les_Destinataires = new List <Member>();

                        la_Liste_Fonction = new List <string>();
                        La_Liste_Role     = new List <string>();
                        Departement       = "";
                        President         = "";
                        Secretaire        = "";
                        La_Liste_AR       = new List <string>();
                        Cric_Members      = "";

                        string[] splits = n.recipient.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
                        foreach (string s in splits)
                        {
                            switch (s.Substring(0, 2))
                            {
                            case "R:":
                                La_Liste_Role.Add(s.Remove(0, 2));
                                break;

                            case "F:":
                                la_Liste_Fonction.Add(s.Remove(0, 2));
                                break;

                            case "D:":
                                Departement = (s.Remove(0, 2));
                                break;

                            case "B:":
                                if (s.Remove(0, 2) == "Président")
                                {
                                    President = s.Remove(0, 2);
                                }
                                else if (s.Remove(0, 2) == "Secrétaire")
                                {
                                    Secretaire = s.Remove(0, 2);
                                }
                                break;

                            case "A:":
                                La_Liste_AR.Add(s.Remove(0, 2));
                                break;

                            case "M:":
                                Cric_Members = s.Remove(0, 2);
                                break;
                            } // Fin Switch
                        }     // Fin foreach

                        if (n.recipient.Contains("R:") || n.recipient.Contains("F:"))
                        {
                            les_Destinataires = Recherche_District();
                        }
                        else
                        {
                            les_Destinataires = Recherche_Club();
                        }

                        if (les_Destinataires != null)
                        {
                            if (les_Destinataires.Count > 0)
                            {
                                bool result = DataMapping.Insert_Newsletter_Out(n, les_Destinataires, "A");

                                if (result == true)
                                {
                                    return(null);
                                }
                                else
                                {
                                    sb.AppendLine("Erreur lors de la création des destinataires de la newsletter " + n.id);
                                }
                            }
                            else
                            {
                                sb.AppendLine("Pas de destinataire(s) dans la newsletter " + n.id);
                            }
                        }
                        else
                        {
                            sb.AppendLine("Problème de récupération des destinataires de la newsletter " + n.id);
                        }
                    }
                    else
                    {
                        sb.AppendLine("Pas de destinataire(s) dans la newsletter " + n.id);
                    }
                }
                else
                {
                    sb.AppendLine("Pas de newsletter en attente.");
                }


                return(sb.ToString());
            }
            catch (Exception ee)
            {
                return(ee.Message);
            }
        }
    }
    /// <summary>
    /// Sets data to database.
    /// </summary>
    protected void btnOK_Click(object sender, EventArgs e)
    {
        // Check 'configure' permission
        if (!CMSContext.CurrentUser.IsAuthorizedPerResource("cms.newsletter", "configure"))
        {
            RedirectToCMSDeskAccessDenied("cms.newsletter", "configure");
        }

        // Validate base inputs (newsletter display name, code name, sender name, sender e-mail)
        string errorMessage = new Validator().NotEmpty(txtNewsletterDisplayName.Text.Trim(), GetString("general.requiresdisplayname")).NotEmpty(txtNewsletterName.Text.Trim(), GetString("Newsletter_Edit.ErrorEmptyName")).NotEmpty(txtNewsletterSenderName.Text.Trim(), GetString("Newsletter_Edit.ErrorEmptySenderName")).NotEmpty(txtNewsletterSenderEmail.Text.Trim(), GetString("Newsletter_Edit.ErrorEmptySenderEmail")).IsEmail(txtNewsletterSenderEmail.Text.Trim(), GetString("Newsletter_Edit.ErrorEmailFormat")).IsCodeName(txtNewsletterName.Text.Trim(), GetString("general.invalidcodename")).Result;

        if (String.IsNullOrEmpty(errorMessage))
        {
            if (String.IsNullOrEmpty((string)subscriptionTemplate.Value))
            {
                // No subscription template selected
                lblSubscriptionError.Visible = true;
                return;
            }

            if (String.IsNullOrEmpty((string)unsubscriptionTemplate.Value))
            {
                // No unsubscription template selected
                lblUnsubscriptionError.Visible = true;
                return;
            }

            if ((radTemplateBased.Checked) && (String.IsNullOrEmpty((string)issueTemplate.Value)))
            {
                // No issue template selected for template based newsletter
                lblIssueError.Visible = true;
                return;
            }

            if ((radDynamic.Checked) && (!ScheduleInterval.CheckOneDayMinimum()))
            {
                // Problem occurred while setting schedule interval for dynamic newsletter
                lblError.Visible = true;
                lblError.Text = GetString("Newsletter_Edit.NoDaySelected");
                return;
            }

            // Newsletter code name must to be unique per site...
            Newsletter newsletterObj = NewsletterProvider.GetNewsletter(txtNewsletterName.Text.Trim(), CMSContext.CurrentSiteID);

            // If newsletter code name is unique...
            if (newsletterObj == null)
            {
                // Create new item -> insert
                newsletterObj = new Newsletter();

                newsletterObj.NewsletterDisplayName = txtNewsletterDisplayName.Text.Trim();
                newsletterObj.NewsletterName = txtNewsletterName.Text.Trim();

                int selectedValue = ValidationHelper.GetInteger(subscriptionTemplate.Value, 0);
                if (selectedValue != 0)
                {
                    newsletterObj.NewsletterSubscriptionTemplateID = selectedValue;
                }
                else
                {
                    lblError.Visible = true;
                    lblError.Text = GetString("Newsletter_Edit.NoSubscriptionTemplateSelected");
                    return;
                }

                selectedValue = ValidationHelper.GetInteger(unsubscriptionTemplate.Value, 0);
                if (selectedValue != 0)
                {
                    newsletterObj.NewsletterUnsubscriptionTemplateID = selectedValue;
                }
                else
                {
                    lblError.Visible = true;
                    lblError.Text = GetString("Newsletter_Edit.NoUnsubscriptionTemplateSelected");
                    return;
                }
                newsletterObj.NewsletterSenderName = txtNewsletterSenderName.Text.Trim();
                newsletterObj.NewsletterSenderEmail = txtNewsletterSenderEmail.Text.Trim();
                if (radDynamic.Checked)
                {
                    newsletterObj.NewsletterDynamicURL = txtNewsletterDynamicURL.Text.Trim();
                    newsletterObj.NewsletterType = NewsletterType.Dynamic;
                }
                else
                {
                    selectedValue = ValidationHelper.GetInteger(issueTemplate.Value, 0);
                    if (selectedValue != 0)
                    {
                        newsletterObj.NewsletterTemplateID = selectedValue;
                    }
                    else
                    {
                        lblError.Visible = true;
                        lblError.Text = GetString("Newsletter_Edit.NoEmailTemplateSelected");
                        return;
                    }
                    newsletterObj.NewsletterType = NewsletterType.TemplateBased;
                }
                newsletterObj.NewsletterSiteID = CMSContext.CurrentSiteID;
                newsletterObj.NewsletterGUID = Guid.NewGuid();
                newsletterObj.NewsletterLogActivity = true;

                if (NewsletterProvider.LicenseVersionCheck(URLHelper.GetCurrentDomain(), FeatureEnum.Newsletters, VersionActionEnum.Insert))
                {
                    // Create new newsletter
                    NewsletterProvider.SetNewsletter(newsletterObj);

                    if (radDynamic.Checked)
                    {
                        if (chkSchedule.Checked)
                        {
                            // Create new task to schedule the dynamic newsletter
                            TaskInfo task = new TaskInfo();
                            task.TaskAssemblyName = "CMS.Newsletter";
                            task.TaskClass = "CMS.Newsletter.DynamicNewsletterSender";
                            task.TaskDisplayName = GetString("DynamicNewsletter.TaskName") + newsletterObj.NewsletterDisplayName;
                            task.TaskEnabled = true;
                            task.TaskInterval = ScheduleInterval.ScheduleInterval;
                            task.TaskLastResult = string.Empty;
                            task.TaskName = "DynamicNewsletter." + ValidationHelper.GetCodeName(newsletterObj.NewsletterName, "_");
                            task.TaskSiteID = CMSContext.CurrentSiteID;
                            task.TaskNextRunTime = SchedulingHelper.GetNextTime(task.TaskInterval, new DateTime(), new DateTime());
                            task.TaskData = newsletterObj.NewsletterGUID.ToString();
                            // Set task for processing in external service
                            task.TaskAllowExternalService = true;
                            task.TaskUseExternalService = (SchedulingHelper.UseExternalService && NewsletterProvider.UseExternalServiceForDynamicNewsletters(CMSContext.CurrentSiteName));

                            TaskInfoProvider.SetTaskInfo(task);

                            newsletterObj.NewsletterDynamicScheduledTaskID = task.TaskID;
                            NewsletterProvider.SetNewsletter(newsletterObj);
                        }
                    }
                    URLHelper.Redirect("Newsletter_Frameset.aspx?newsletterid=" + ValidationHelper.GetString(newsletterObj.NewsletterID, null) + "&saved=1");
                }
                else
                {
                    lblError.Visible = true;
                    lblError.Text = GetString("LicenseVersionCheck.Newsletter");
                }
            }
            else
            {
                lblError.Visible = true;
                lblError.Text = GetString("Newsletter_Edit.NewsletterNameExists");
            }
        }
        else
        {
            lblError.Visible = true;
            lblError.Text = errorMessage;
        }
    }
Beispiel #52
0
    } // End of the MasterPostExists method

    /// <summary>
    /// Get one newsletter post based on id
    /// </summary>
    /// <param name="id">The id for the newsletter</param>
    /// <returns>A reference to a newsletter post</returns>
    public static Newsletter GetOneById(Int32 id)
    {
        // Create the post to return
        Newsletter post = null;

        // Create the connection and the sql statement
        string connection = Tools.GetConnectionString();
        string sql = "SELECT * FROM dbo.newsletters WHERE id = @id;";

        // The using block is used to call dispose automatically even if there are an exception
        using (SqlConnection cn = new SqlConnection(connection))
        {
            // The using block is used to call dispose automatically even if there are an exception
            using (SqlCommand cmd = new SqlCommand(sql, cn))
            {
                // Add parameters
                cmd.Parameters.AddWithValue("@id", id);

                // Create a MySqlDataReader
                SqlDataReader reader = null;

                // The Try/Catch/Finally statement is used to handle unusual exceptions in the code to
                // avoid having our application crash in such cases
                try
                {
                    // Open the connection.
                    cn.Open();

                    // Fill the reader with one row of data
                    reader = cmd.ExecuteReader();

                    // Loop through the reader as long as there is something to read and add values
                    while (reader.Read())
                    {
                        post = new Newsletter(reader);
                    }
                }
                catch (Exception e)
                {
                    throw e;
                }
                finally
                {
                    // Call Close when done reading to avoid memory leakage
                    if (reader != null)
                        reader.Close();
                }
            }
        }

        // Return the post
        return post;

    } // End of the GetOneById method
Beispiel #53
0
 public IActionResult Edit(Newsletter newsletter)
 {
     _db.Entry(newsletter).State = EntityState.Modified;
     _db.SaveChanges();
     return(RedirectToAction("Index"));
 }
 private static TaskInfo GetDynamicNewsletterTask(Newsletter newsletterObj)
 {
     return TaskInfoProvider.GetTaskInfo(ValidationHelper.GetInteger(newsletterObj.NewsletterDynamicScheduledTaskID, 0)) ??
            CreateDynamicNewsletterTask(newsletterObj);
 }
        public ActionResult edit(FormCollection collection)
        {
            // Get the current domain
            Domain currentDomain = Tools.GetCurrentDomain();
            ViewBag.CurrentDomain = currentDomain;

            // Get query parameters
            string returnUrl = collection["returnUrl"];
            ViewBag.QueryParams = new QueryParams(returnUrl);

            // Check if the administrator is authorized
            if (Administrator.IsAuthorized(new string[] { "Administrator", "Editor" }) == true)
            {
                ViewBag.AdminSession = true;
            }
            else if (Administrator.IsAuthorized(Administrator.GetAllAdminRoles()) == true)
            {
                ViewBag.AdminSession = true;
                ViewBag.AdminErrorCode = 1;
                ViewBag.TranslatedTexts = StaticText.GetAll(currentDomain.back_end_language, "id", "ASC");
                return View("index");
            }
            else
            {
                // Redirect the user to the start page
                return RedirectToAction("index", "admin_login");
            }

            // Get all the form values
            Int32 id = Convert.ToInt32(collection["hiddenId"]);
            Int32 languageId = Convert.ToInt32(collection["selectLanguage"]);
            string title = collection["txtTitle"];
            string content = collection["txtContent"];

            // Get the default admin language id
            Int32 adminLanguageId = currentDomain.back_end_language;

            // Get translated texts
            KeyStringList tt = StaticText.GetAll(adminLanguageId, "id", "ASC");

            // Get the newsletter
            Newsletter newsletter = Newsletter.GetOneById(id);
            bool postExists = true;

            // Check if the newsletter exists
            if (newsletter == null)
            {
                // Create an empty newsletter
                newsletter = new Newsletter();
                postExists = false;
            }

            // Update values
            newsletter.language_id = languageId;
            newsletter.title = title;
            newsletter.content = content;
            
            // Create a error message
            string errorMessage = string.Empty;

            // Check for errors
            if (newsletter.language_id == 0)
            {
                errorMessage += "&#149; " + String.Format(tt.Get("error_select_value"), tt.Get("language").ToLower()) + "<br/>";
            }
            if (newsletter.title.Length > 100)
            {
                errorMessage += "&#149; " + String.Format(tt.Get("error_field_length"), tt.Get("title"), "100") + "<br/>";
            }

            // Check if there is errors
            if (errorMessage == string.Empty)
            {
                // Check if we should add or update the newsletter
                if (postExists == false)
                {
                    // Add the newsletter
                    Newsletter.Add(newsletter);
                }
                else
                {
                    // Update the newsletter
                    Newsletter.Update(newsletter);
                }

                // Redirect the user to the list
                return Redirect("/admin_newsletters" + returnUrl);
            }
            else
            {
                // Set form values
                ViewBag.ErrorMessage = errorMessage;
                ViewBag.Languages = Language.GetAll(adminLanguageId, "name", "ASC");
                ViewBag.TranslatedTexts = tt;
                ViewBag.Newsletter = newsletter;
                ViewBag.ReturnUrl = returnUrl;

                // Return the edit view
                return View("edit");
            }

        } // End of the edit method
 private void SetNewsletterValues(Newsletter newsletterObj)
 {
     newsletterObj.NewsletterDisplayName = txtNewsletterDisplayName.Text.Trim();
     newsletterObj.NewsletterName = txtNewsletterName.Text.Trim();
     newsletterObj.NewsletterSenderName = txtNewsletterSenderName.Text.Trim();
     newsletterObj.NewsletterSenderEmail = txtNewsletterSenderEmail.Text.Trim();
     newsletterObj.NewsletterBaseUrl = txtNewsletterBaseUrl.Text.Trim();
     newsletterObj.NewsletterUnsubscribeUrl = txtNewsletterUnsubscribeUrl.Text.Trim();
     newsletterObj.NewsletterDraftEmails = txtDraftEmails.Text;
     newsletterObj.NewsletterUseEmailQueue = chkUseEmailQueue.Checked;
     newsletterObj.NewsletterTrackOpenEmails = onlineMarketingEnabled && chkTrackOpenedEmails.Checked;
     newsletterObj.NewsletterTrackClickedLinks = onlineMarketingEnabled && chkTrackClickedLinks.Checked;
     newsletterObj.NewsletterLogActivity = onlineMarketingEnabled && chkLogActivity.Checked;
     newsletterObj.NewsletterEnableOptIn = chkEnableOptIn.Checked;
     newsletterObj.NewsletterOptInApprovalURL = txtOptInURL.Text.Trim();
     newsletterObj.NewsletterSendOptInConfirmation = chkSendOptInConfirmation.Checked;
 }
Beispiel #57
0
        public void DeleteTest()
        {
            NewsletterDAL target = new NewsletterDAL();
            Newsletter newsletter = new Newsletter();

            newsletter.IdNewsletter = 1;

            target.Delete(newsletter);
        }