/// <summary> /// Adds the specified mass mail. /// </summary> /// <param name="massMail">The mass mail.</param> /// <returns></returns> public tbl_MassMail Add(tbl_MassMail massMail) { massMail.ID = Guid.NewGuid(); _dataContext.tbl_MassMail.AddObject(massMail); _dataContext.SaveChanges(); return(massMail); }
/// <summary> /// Saves this instance. /// </summary> protected void Save() { if (!Page.IsValid) { return; } if (!access.Write) { return; } tbl_MassMail massMail = null; massMail = DataManager.MassMail.SelectById(SiteId, _massMailId) ?? new tbl_MassMail(); massMail.SiteID = SiteId; massMail.Name = txtName.Text; massMail.SiteActionTemplateID = SaveSiteActionTemplate(); massMail.OwnerID = CurrentUser.Instance.ContactID; if (_massMailId == Guid.Empty && rdtpSchedule.SelectedDate != null) { massMail.MailDate = rdtpSchedule.SelectedDate; } else { if (rdtpMailDate.SelectedDate != null) { massMail.MailDate = rdtpMailDate.SelectedDate; } } if (massMail.ID == Guid.Empty) { if (rblTargetContacts.SelectedValue == "0") { massMail.SiteTagID = rblTags.SelectedValue.ToGuid(); SelectedContactList.Clear(); } else { massMail.SiteTagID = null; } massMail.MassMailStatusID = (int)MassMailStatus.Scheduled; massMail = DataManager.MassMail.Add(massMail); } else { DataManager.MassMail.Update(massMail); } DataManager.MassMailContact.Save(SiteId, SelectedContactList, massMail.ID); _massMailId = massMail.ID; }
/// <summary> /// Handles the Click event of the BtnSave control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void BtnSave_Click(object sender, EventArgs e) { if (!access.Write) { return; } var massMail = new tbl_MassMail(); if (_massMailId != Guid.Empty) { massMail = DataManager.MassMail.SelectById(SiteId, _massMailId); } massMail.SiteID = SiteId; massMail.Name = ((TextBox)fvMassMail.FindControl("txtName")).Text; //massMail.SiteActionTemplateID = (Guid)((UserControls.SiteActionTemplate)fvMassMail.FindControl("ucSiteActionTemplate")).SelectedSiteActionTemplateId; massMail.SiteActionTemplateID = ((SelectSiteActionTemplate)fvMassMail.FindControl("ucSelectSiteActionTemplate")).SiteActionTemplateId; massMail.MassMailStatusID = int.Parse(((DropDownList)fvMassMail.FindControl("ddlMassMailStatus")).SelectedValue); if (!string.IsNullOrEmpty(((TextBox)fvMassMail.FindControl("txtFocusGroup")).Text)) { massMail.FocusGroup = int.Parse(((TextBox)fvMassMail.FindControl("txtFocusGroup")).Text); } if (_massMailId != Guid.Empty) { DataManager.MassMail.Update(massMail); } else { massMail.OwnerID = CurrentUser.Instance.ContactID; massMail = DataManager.MassMail.Add(massMail); } //((UserControls.SiteActionTemplate)fvMassMail.FindControl("ucSiteActionTemplate")).UpdateSiteActionTemplate(massMail.ID, massMail.SiteActionTemplateID); tagsMassMail.SaveTags(massMail.ID); Response.Redirect(UrlsData.AP_MassMail(massMail.ID)); }
/// <summary> /// Updates the specified mass mail. /// </summary> /// <param name="massMail">The mass mail.</param> public void Update(tbl_MassMail massMail) { _dataContext.SaveChanges(); }