public void Initialized_MailingList_With_Null_Address_And_Optional_Fields_Should_Throw_Exception(string name, string description, AccessLevel accessLevel) { Assert.Throws <ArgumentNullException>(() => { var list = new MailingList(null, name, description, accessLevel); }); }
// GET: Mailing public ActionResult Index() { MailingList m1 = new MailingList(); m1.FirstName = "Griffin"; m1.LastName = "Dotson"; m1.Email = "*****@*****.**"; MailingList m2 = new MailingList(); m2.FirstName = "Normal"; m2.LastName = "Mailer"; m2.Email = "*****@*****.**"; MailingList m3 = new MailingList(); m3.FirstName = "Sarah"; m3.LastName = "Jones"; m3.Email = "*****@*****.**"; List <MailingList> mailings = new List <MailingList>(); mailings.Add(m1); mailings.Add(m2); mailings.Add(m3); return(View(mailings)); }
public ActionResult Create(MailingList mailinglist, int?seminarId) { // make sure it's not a system mailing list if (_systemLists.Contains(mailinglist.Name)) { ModelState.AddModelError("Name", "The name is the same as a system defined mailing list."); } // make sure one doesn't already exist if (mailinglist.Seminar.MailingLists.Any(a => a.Name == mailinglist.Name)) { ModelState.AddModelError("Name", string.Format("A mailing list with the same name already exists for the {0} seminar.", mailinglist.Seminar.Year)); } if (ModelState.IsValid) { _mailinglistRepository.EnsurePersistent(mailinglist); Message = "MailingList Created Successfully"; //return RedirectToAction("Index"); return(this.RedirectToAction(a => a.Index(seminarId))); } var viewModel = MailingListViewModel.Create(RepositoryFactory, Site, mailinglist, seminarId); viewModel.MailingList = mailinglist; return(View(viewModel)); }
public void TestDelete() { var testList = new MailingList { Name = "a", MailingListLines = new Collection <MailingListLine> { new MailingListLine { Address = new Address { Email = "*****@*****.**", FirstName = "yay", LastName = "demmetasdfadsf", ReceivedMails = new List <ReceivedMail>() } } } }; using (var db = new MailerEntities()) { db.MailingLists.Add(testList); db.SaveChanges(); var mlivmTest = new MailingListItemViewModel(testList, true); mlivmTest.Delete(); Assert.IsFalse(db.MailingLists.Any(ml => ml.ListID == testList.ListID)); } }
protected void LinkButton1_Click1(object sender, EventArgs e) { if (Page.IsValid) { using (var db = drvvv.drvvvSettings.GetDataContextInstance()) { var cMailingLists = db.MailingLists.Where(x => x.SiteID == 1 && x.Email == TextBoxMailingList.Text.Trim()).FirstOrDefault(); if (cMailingLists == null) { MailingList inMailingList = new MailingList(); inMailingList.Email = TextBoxMailingList.Text; inMailingList.InDate = DateTime.Now; inMailingList.Lang = 1; inMailingList.Ip = Request.ServerVariables["REMOTE_ADDR"]; inMailingList.SiteID = (int)drvvv.drvvvSettings.GetSite(); db.MailingLists.InsertOnSubmit(inMailingList); db.SubmitChanges(); Page.RegisterStartupScript("alert", "<script language='javascript'> { alert('Have successfully registered');}</script>"); } else Page.RegisterStartupScript("alert", "<script language='javascript'> { alert('E-mail address already exists in');}</script>"); } } }
public void UnaListaPuoEssereCancellataPerId() { var repository = new MailingListRepository(new DbContext(connectionString)); var mailingList1 = new MailingList("TestNomeDelete") { Emails = new List <string>() { "*****@*****.**", "*****@*****.**", "*****@*****.**" } }; var mailingList2 = new MailingList("TestNomeDelete1") { Emails = new List <string>() { "*****@*****.**", "*****@*****.**", "*****@*****.**" } }; repository.Save(mailingList1); var idDaEliminare = mailingList1.Id; repository.Save(mailingList2); repository.Delete(idDaEliminare); var mailingLists = repository.Get(); Assert.AreEqual(new string[] { mailingList2.Id }, mailingLists.Select(ml => ml.Id)); }
/// <summary> /// Adds or updates mailing list as needed. Returns true if operation was successful. /// </summary> private bool AddOrUpdate() { //--- Validate values ----------------------------------------------// if(m_pMailingListName.Text == ""){ MessageBox.Show(this,"Please fill mailing list name !","Error:",MessageBoxButtons.OK,MessageBoxIcon.Error); return false; } if(m_pDomains.SelectedIndex == -1){ MessageBox.Show(this,"Please choose domain !","Error:",MessageBoxButtons.OK,MessageBoxIcon.Error); return false; } //------------------------------------------------------------------// // Add new mailing list if(m_pMailingList == null){ m_pMailingList = m_pVirtualServer.MailingLists.Add( m_pMailingListName.Text + "@" + m_pDomains.SelectedItem.ToString(), m_pDescription.Text, m_pEnabled.Checked ); } // Update mailing list else{ m_pMailingList.Enabled = m_pEnabled.Checked; m_pMailingList.Name = m_pMailingListName.Text + "@" + m_pDomains.SelectedItem.ToString(); m_pMailingList.Description = m_pDescription.Text; m_pMailingList.Commit(); } return true; }
public static void MailingListTest() { var url = new Uri("https://api.eveonline.com/char/mailinglists.xml.aspx"); const int characterId = 123456; Dictionary <string, string> data = ApiTestHelpers.GetBaseTestParams(); data.Add(ApiConstants.CharacterId, characterId.ToString(CultureInfo.InvariantCulture)); IHttpRequestProvider mockProvider = MockRequests.GetMockedProvider(url, data, ApiTestHelpers.GetXmlData("TestData\\Api\\Mailinglists.xml")); using ( var client = new EveAPI(ApiTestHelpers.EveServiceApiHost, ApiTestHelpers.GetNullCacheProvider(), mockProvider)) { Task <EveServiceResponse <IEnumerable <MailingList> > > task = client.Character.MailingListsAsync(ApiTestHelpers.KeyIdValue, ApiTestHelpers.VCodeValue, characterId); task.Wait(); ApiTestHelpers.BasicSuccessResultValidations(task); EveServiceResponse <IEnumerable <MailingList> > result = task.Result; Assert.AreEqual(3, result.ResultData.Count()); MailingList sample = result.ResultData.Skip(1).Take(1).First(); Assert.AreEqual(128783669, sample.ListId); Assert.AreEqual("EVEMarkerScanner", sample.DisplayName); } }
public void DueListePossonoEssereSalvate() { var repository = new MailingListRepository(new DbContext(connectionString)); var mailingList1 = new MailingList("TestNome1") { Emails = new List <string>() { "*****@*****.**", "*****@*****.**", "*****@*****.**" } }; var mailingList2 = new MailingList("TestNome2") { Emails = new List <string>() { "*****@*****.**", "*****@*****.**", "*****@*****.**" } }; repository.Save(mailingList1); repository.Save(mailingList2); var mailingLists = repository.Get(); Assert.Multiple(() => { Assert.That(mailingLists.Count(), Is.EqualTo(2)); CollectionAssert.AreEquivalent(new[] { "TestNome1", "TestNome2" }, mailingLists.Select(ml => ml.Nome)); } ); }
public static void CampaignTestsInitialize(TestContext testContext) { message = new Message(); mailingList = new MailingList(); category = new Category(); campaign = new Campaign(); }
/// <summary> /// Add the specified MailingList entity as a recipient of this message. /// </summary> /// <param name="list">The MailingList entity to add as a recipient.</param> public RecipientViewModel AddRecipient(MailingList list) { RecipientViewModel vm = new MailingListRecipientViewModel(this, list); Recipients.Add(vm); return(vm); }
/// <summary> /// Executes specified tool bar task. /// </summary> /// <param name="taskID">Task ID.</param> private void SwitchToolBarTask(string taskID) { if (taskID == "add") { wfrm_MailingList frm = new wfrm_MailingList(m_pVirtualServer); if (frm.ShowDialog(this) == DialogResult.OK) { LoadMailingLists(frm.MailingListID); } } else if (taskID == "edit") { MailingList mailingList = (MailingList)m_pMailingLists.SelectedItems[0].Tag; wfrm_MailingList frm = new wfrm_MailingList(m_pVirtualServer, mailingList); if (frm.ShowDialog(this) == DialogResult.OK) { LoadMailingLists(frm.MailingListID); } } else if (taskID == "delete") { MailingList mailingList = (MailingList)m_pMailingLists.SelectedItems[0].Tag; if (MessageBox.Show(this, "Are you sure you want to delete Mailing List '" + mailingList.Name + "' !", "Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { mailingList.Owner.Remove(mailingList); m_pMailingLists.SelectedItems[0].Remove(); } } else if (taskID == "refresh") { LoadMailingLists(""); } }
public ActionResult Index(MailingList mailing, int?mailingID) { var mailings = db.MailingLists.Where(x => x.Enabled).OrderBy(x => x.Name).AsEnumerable().ToList(); mailings.Insert(0, new MailingList { ID = 0, Name = "--Выберите рассылку в списке--" }); ViewBag.Mailings = new SelectList(mailings, "ID", "Name", mailingID ?? 0); var mail = db.MailingLists.FirstOrDefault(x => x.ID == mailing.ID); if (mail == null) { ModelState.AddModelError("", "Ошибка сохранения! Рассылка не найдена в БД"); return(View(mailing)); } mail.Header = mailing.Header; mail.Letter = mailing.Letter; mail.TargetMail = mailing.TargetMail; if (!mail.MailingReplacements.All(x => mailing.Letter.IndexOf(x.Replacement) >= 0)) { ModelState.AddModelError("", "Ошибка! Данные не сохранены - Все подстановки из списка должны быть использованы в тексте письма"); return(View(mail)); } db.SubmitChanges(); ModelState.AddModelError("", "Данные успешно сохранены"); return(View(mail)); }
public async Task TestDeleteMailingList() { DbContextOptions <FoodProductsContext> options = new DbContextOptionsBuilder <FoodProductsContext>().UseInMemoryDatabase(databaseName: "DeleteMailingList").Options; using (var context = new FoodProductsContext(options)) { context.MailingList.Add(new MailingList() { Email = "*****@*****.**" }); context.SaveChanges(); MailingList mailingList1 = context.MailingList.First(); MailingListsController mailingListsController = new MailingListsController(context); IActionResult result = await mailingListsController.DeleteMailingList(mailingList1.Id) as IActionResult; var okObjectResult = result as OkObjectResult; Assert.IsNotNull(okObjectResult); var model = okObjectResult.Value as MailingList; Assert.IsNotNull(model); Assert.AreNotEqual(0, model.Id); Assert.AreEqual(mailingList1.Email, model.Email); Assert.AreEqual(false, context.MailingList.Any(x => x.Id == mailingList1.Id)); } }
public async Task CreateList_WithValidCustomFields_ReturnsListId() { //arrange var expectedResponse = "1"; var list = new MailingList { BrandId = 1, Name = "Foo list" }; list.CustomFields.Add(new CustomField("custom field 1")); list.CustomFields.Add(new CustomField("custom field 2", CustomField.DataTypes.Date)); var expectedPostData = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("list_name", list.Name), new KeyValuePair <string, string>("brand_id", list.BrandId.ToString()), new KeyValuePair <string, string>("custom_fields", "custom field 1,custom field 2"), new KeyValuePair <string, string>("field_types", "Text,Date") }; _httpMessageHandlerMock.Expect("/api/lists/create.php") .WithFormData(expectedPostData) .Respond("text/plain", expectedResponse); //act var result = await _target.CreateList(list); //assert _httpMessageHandlerMock.VerifyNoOutstandingExpectation(); Assert.True(result.IsSuccess); Assert.Equal(expectedResponse, result.Response); }
private bool Save() { bool result = false; MailingList m = MTApp.ContactServices.MailingLists.Find(CurrentId); if (m == null) { m = new MailingList(); } m.Name = this.NameField.Text.Trim(); m.IsPrivate = this.IsPrivateField.Checked; if (m.Id < 1) { result = MTApp.ContactServices.MailingLists.Create(m); } else { result = MTApp.ContactServices.MailingLists.Update(m); } if (result == false) { this.lblError.Text = "Unable to save mailing list. Uknown error."; } else { // Update bvin field so that next save will call updated instead of create CurrentId = m.Id; } return(result); }
public void AddMailingListItemViewModelTest() { var mlvmTest = new MailingListViewModel(); var testList = new MailingList { Name = "a", MailingListLines = new Collection <MailingListLine> { new MailingListLine { Address = new Address { Email = "*****@*****.**", FirstName = "yay", LastName = "demmetasdfadsf", ReceivedMails = new List <ReceivedMail>() } } } }; var mlivmTemp = new MailingListItemViewModel(testList, true); mlvmTest.AddMailingListItemViewModel(mlivmTemp); Assert.IsTrue(mlvmTest.MailingListItemViewModels.Contains(mlivmTemp)); }
public void Constructor() { var propertyValueListResponse = BuildTPropertyValueListResponseFromFile("MailingList_TPropertyValueListResponse.xml"); Assert.NotNull(propertyValueListResponse); Assert.NotNull(propertyValueListResponse.HttpRequestResult); Assert.NotNull(propertyValueListResponse.Items); Assert.AreEqual(61, propertyValueListResponse.Items.Count); var account = new MailingList(propertyValueListResponse.Items); //shared properties Assert.True(account.U_Type.HasValue); Assert.AreEqual(AccountType.MailingList, account.U_Type.Value); Assert.AreEqual("all-users", account.U_Alias); Assert.AreEqual("*****@*****.**", account.U_AliasList); Assert.AreEqual("All Users", account.U_Name); Assert.AreEqual("eJxjZGBg4HLMyVEILU4tKrZmGGGAEURwJubk6JaC/D/QzhkYIFSSWlziACIy89L1kvP1SrMH2kn0BYwyKJ6PgacHvZKKkhGRJxgZR4Q3cQPGgXbAKBgFIKCKWRjXZOal5Y/k8pmugIlRKAQY1Aq+iZk5wPBW8MksLqkZEHcMgKWjAA0AAAkmLuw=", account.U_Backup); Assert.False(account.U_GW_DailyAgenda.HasValue); //account type specific properties Assert.AreEqual(@"testing.co.uk\all-users.txt", account.M_ListFile); Assert.True(account.M_SeparateTo.HasValue); Assert.True(account.M_SeparateTo.Value); Assert.True(account.M_MaxListSize.HasValue); Assert.AreEqual(0, account.M_MaxListSize); Assert.True(account.M_SetSender.HasValue); Assert.AreEqual(MailingListSetSender.SetReplyTo_ToSender, account.M_SetSender.Value); }
public void Setup() { _list = new MailingList("alice@localhost", "bob@localhost", "alice@localhost", "carol@localhost"); }
public async Task CreateList_WithInValidData_ReturnsError() { //arrange var expectedResponse = "List name is required"; var list = new MailingList { BrandId = 1, Name = string.Empty }; var expectedPostData = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("list_name", list.Name), new KeyValuePair <string, string>("brand_id", list.BrandId.ToString()), }; _httpMessageHandlerMock.Expect("/api/lists/create.php") .WithFormData(expectedPostData) .Respond("text/plain", expectedResponse); //act var result = await _target.CreateList(list); //assert _httpMessageHandlerMock.VerifyNoOutstandingExpectation(); Assert.False(result.IsSuccess); Assert.Equal(expectedResponse, result.ErrorMessage); }
public ActionResult SimpleRestore(RestoreModel model) { if (model.Email.IsNullOrEmpty() || !model.Email.IsMailAdress()) { model.ErrorText = "Для восстановления пароля необходимо указать Email, использованный при регистрации"; } else { var user = Membership.FindUsersByEmail(model.Email); if (user.Count == 0) { model.ErrorText = "Пользователь с таким Email не регистрировался на сайте"; } else { foreach (MembershipUser u in user) { var res = MailingList.Get("RestorePassLetter") .To(model.Email) .WithReplacement(new MailReplacement("{PASSWORD}", u.GetPassword())).Send(); model.ErrorText = res.IsFilled() ? res : "Пароль для доступа к сайту был успешно отправлен на указанный Email"; } } } return(PartialView(model)); }
private bool AddOrUpdate() { if (this.m_pMailingListName.Text == "") { MessageBox.Show(this, "Please fill mailing list name !", "Error:", MessageBoxButtons.OK, MessageBoxIcon.Hand); return(false); } if (this.m_pDomains.SelectedIndex == -1) { MessageBox.Show(this, "Please choose domain !", "Error:", MessageBoxButtons.OK, MessageBoxIcon.Hand); return(false); } if (this.m_pMailingList == null) { this.m_pMailingList = this.m_pVirtualServer.MailingLists.Add(this.m_pMailingListName.Text + "@" + this.m_pDomains.SelectedItem.ToString(), this.m_pDescription.Text, this.m_pEnabled.Checked); } else { this.m_pMailingList.Enabled = this.m_pEnabled.Checked; this.m_pMailingList.Name = this.m_pMailingListName.Text + "@" + this.m_pDomains.SelectedItem.ToString(); this.m_pMailingList.Description = this.m_pDescription.Text; this.m_pMailingList.Commit(); } return(true); }
public void Initialized_MailingList_With_Null_Address_Should_Throw_Exception() { Assert.Throws <ArgumentNullException>(() => { var list = new MailingList(null); }); }
public void AlertServiceTest() { User user = new User { UserId = 1, EmailAddress = "*****@*****.**" }; MailingList pressReleaseList = new MailingList(); pressReleaseList.Subscribers.Add(user); PressRelease pressRelease = new PressRelease { PressReleaseId = 1, Headline = "Test Release", Body = "Press release body", IsActive = true, IsDeleted = false, MailingList = pressReleaseList }; Logger logger = new Logger(); EmailSender emailSender = new EmailSender(logger); PressReleaseAlertService pressReleaseAlertService = new PressReleaseAlertService(emailSender); pressReleaseAlertService.SendAlerts(pressRelease); }
public CartItem AddCartItem(NewCartItem newItem, MailingList mailingList = null) { var addedAmount = newItem?.Quantity ?? 0; if (addedAmount < 1) { throw new ArgumentException(resources.GetResourceString("Kadena.Product.InsertedAmmountValueIsNotValid")); } var productDocument = DocumentHelper.GetDocument(newItem.DocumentId, new TreeProvider(MembershipContext.AuthenticatedUser)); var productType = productDocument.GetValue("ProductType", string.Empty); var isTemplatedType = ProductTypes.IsOfType(productType, ProductTypes.TemplatedProduct); var cartItem = ECommerceContext.CurrentShoppingCart.CartItems .FirstOrDefault(i => i.SKUID == productDocument.NodeSKUID && i.GetValue("ChilliEditorTemplateID", Guid.Empty) == newItem.TemplateId); var isNew = false; if (cartItem == null) { isNew = true; cartItem = isTemplatedType ? CreateCartItem(productDocument, newItem.TemplateId) : CreateCartItem(productDocument); } var existingAmountInCart = isNew ? 0 : cartItem.CartItemUnits; if (productType.Contains(ProductTypes.InventoryProduct)) { EnsureInventoryAmount(productDocument, addedAmount, existingAmountInCart); } var isMailingType = ProductTypes.IsOfType(productType, ProductTypes.MailingProduct); if (isTemplatedType || isMailingType) { if (isMailingType) { if (mailingList?.AddressCount != addedAmount) { throw new ArgumentException(resources.GetResourceString("Kadena.Product.InsertedAmmountValueIsNotValid")); } SetMailingList(cartItem, mailingList); } SetAmount(cartItem, addedAmount); } else { SetAmount(cartItem, addedAmount + existingAmountInCart); } SetArtwork(cartItem, productDocument.GetStringValue("ProductArtwork", string.Empty)); RefreshPrice(cartItem, productDocument); SetCustomName(cartItem, newItem.CustomProductName); ShoppingCartItemInfoProvider.SetShoppingCartItemInfo(cartItem); return(GetShoppingCartItems().FirstOrDefault(i => i.Id == cartItem.CartItemID)); }
public PartialViewResult Restore(RestoreModel model) { if (model.Email.IsNullOrEmpty() || !model.Email.IsMailAdress()) { ModelState.AddModelError("", LabelDictionary.Translate( "Для восстановления пароля необходимо указать Email, использованный при регистрации")); } else { var user = Membership.GetUser(model.Email); if (user == null) { ModelState.AddModelError("", LabelDictionary.Translate( "Пользователь с таким Email не регистрировался на сайте")); } else { var res = MailingList.Get("RestorePassLetter") .To(model.Email) .WithReplacement(new MailReplacement("{PASSWORD}", user.GetPassword())).Send(); ModelState.AddModelError("", res.IsFilled() ? res : LabelDictionary.Translate( "Пароль для доступа к сайту был успешно отправлен на указанный Email")); } } return(PartialView(model)); }
// GET: MailingList public ActionResult Index() { MailingList m1 = new MailingList(); m1.FirstName = "Steve"; m1.LastName = "Conger"; m1.EMail = "*****@*****.**"; MailingList m2 = new MailingList(); m2.FirstName = "Normal"; m2.LastName = "Mailer"; m2.EMail = "*****@*****.**"; MailingList m3 = new MailingList(); m3.FirstName = "Sarah"; m3.LastName = "Jones"; m3.EMail = "*****@*****.**"; List <MailingList> mailings = new List <MailingList>(); // This is a a <generic>. List is like an array, only it must be one-dimensional. mailings.Add(m1); mailings.Add(m2); mailings.Add(m3); return(View(mailings)); // Must pass the List to the View in order to see it. }
public PartialViewResult FeedBackPopup(FeedBackModel form) { if (form.Mail.IsNullOrEmpty()) { form.ErrorText = "Необходимо указать E-mail"; return(PartialView(form)); } if (form.Text.IsNullOrEmpty()) { form.ErrorText = "Необходимо заполнить текст сообщения"; return(PartialView(form)); } var replacements = new List <MailReplacement>(); replacements.Add(new MailReplacement("{TYPE}", form.TypeName)); replacements.Add(new MailReplacement("{MAIL}", form.Mail)); replacements.Add(new MailReplacement("{NAME}", form.Name)); replacements.Add(new MailReplacement("{TEXT}", form.Text)); string result = MailingList.Get("FeedBackLetter") .WithReplacements(replacements) .Send(); if (result.IsNullOrEmpty()) { form.ErrorText = "Ваше сообщение успешно отправлено."; } else { form.ErrorText = "Произошла ошибка при отправке сообщения. Попробуйте повторить попытку позже"; } return(PartialView(form)); }
public void Initialized_MailingList_With_Optional_Fields_Should_Produce_A_NonEmpty_FormContent(string emailAddress, string name, string description, AccessLevel accessLevel) { var list = new MailingList(new MailAddress(emailAddress), name, description, accessLevel); var formContent = list.ToFormContent(); Assert.NotEmpty(formContent); }
private static void SetMailingList(ShoppingCartItemInfo cartItem, MailingList mailingList) { if (mailingList != null) { cartItem.SetValue("MailingListName", mailingList.Name); cartItem.SetValue("MailingListGuid", mailingList.Id); } }
public void CtorTest() { var list = new MailingList(); var rule = new MailingRule("*", list); Assert.That(rule.TypeHierarchy, Is.EqualTo("*")); Assert.That(rule.Recepients, Is.EqualTo(list)); }
public void Initialized_MailingList_With_Optional_Fields_Should_Produce_A_NonEmpty_JsonObject(string emailAddress, string name, string description, AccessLevel accessLevel) { var list = new MailingList(new MailAddress(emailAddress), name, description, accessLevel); var json = list.ToJson(); Assert.NotEmpty(json); }
public ActionResult DeleteConfirmed(int id) { MailingList mailingList = db.MailingLists.Find(id); db.MailingLists.Remove(mailingList); db.SaveChanges(); return(RedirectToAction("Index")); }
//TODO: need cache proxy for this method public MailingList GetRecepients(Type type) { MailingList recepients = new MailingList(); foreach (var rule in _rules.Where(rule => rule.Check(type))) { recepients.UnionWith(rule.Recepients); } return recepients; }
public void Should_make_distinct_union() { var another = new MailingList("bob@localhost", "dave@localhost"); _list.UnionWith(another); Assert.That(_list, Is.EquivalentTo(new[] { "alice@localhost", "bob@localhost", "carol@localhost", "dave@localhost" })); }
public static MailingListViewModel Create(IRepositoryFactory repositoryFactory, string siteId, MailingList mailingList = null, int? seminarId = null) { Check.Require(repositoryFactory!= null, "Repository must be supplied"); var site = SiteService.LoadSite(siteId); var viewModel = new MailingListViewModel { MailingList = mailingList ?? new MailingList(), Seminars = site.Seminars, People = repositoryFactory.PersonRepository.GetAll(), SeminarId = seminarId }; return viewModel; }
public static NotificationTrackingViewModel Create(IRepository repository, string siteId, NotificationTracking notificationTracking = null, Person person = null, MailingList mailingList = null) { Check.Require(repository != null, "Repository is required."); var seminar = SiteService.GetLatestSeminar(siteId); var viewModel = new NotificationTrackingViewModel(){ NotificationTracking = notificationTracking ?? new NotificationTracking(), NotificationMethods = repository.OfType<NotificationMethod>().GetAll(), NotificationTypes = repository.OfType<NotificationType>().GetAll(), People = new List<Person>(), AllPeople = SiteService.GetLatestSeminar(siteId).SeminarPeople.Select(a => a.Person).ToList(),//seminarService.GetCurrent().SeminarPeople.Select(a=>a.Person).ToList(), SitePeople = SiteService.LoadSite(siteId).People, Seminar = seminar, MailingLists = seminar.MailingLists, MailingList = mailingList }; if (person != null) viewModel.People.Add(person); return viewModel; }
/// <summary> /// Invia la mailing list all'elenco dei ruoli /// </summary> /// <param name = "mailingList"></param> /// <param name="lingue"></param> internal static void MailingList(MailingList mailingList, Lingue lingue) { //Prendo tutti gli utenti del ruolo specificato var utenti = UtentiCollection.GetList(wherePredicate: "IdRuoli == " + mailingList.Ruolo.Id + " AND EmailVerificata == True AND Attivo == True AND IdLingue == " + lingue.Id); foreach (var utente in utenti) { Utenti utente1 = utente; string titolo = mailingList.Titolo.Replace(utente1); //Prendo titolo e testo in base alla descrizione string descrizione = mailingList.Descrizione.Replace(utente1); Common.Email.ManagerEmail.InviaEmail(descrizione, titolo, utente1.Email, Settings.Config.Email.SenderMailingList); } }
public MailingRule(string typeHierarchy, MailingList recepients) { TypeHierarchy = typeHierarchy; Recepients = recepients; }
public ActionResult Delete(int id, MailingList mailinglist) { var mailinglistToDelete = _mailinglistRepository.GetNullableById(id); if (mailinglistToDelete == null) return RedirectToAction("Index"); // check to make sure it's not a system mailing list if (_systemLists.Contains(mailinglist.Name)) { Message = "Unable to edit system mailing list."; // redirect to index return this.RedirectToAction(a => a.Index(mailinglist.Seminar.Id)); } _mailinglistRepository.Remove(mailinglistToDelete); Message = "MailingList Removed Successfully"; return RedirectToAction("Index"); }
public ActionResult Edit(int id, MailingList mailinglist) { var existingMailingList = _mailinglistRepository.GetNullableById(id); if (existingMailingList == null) { Message = "Unable to locate mailing list."; return this.RedirectToAction(a => a.Index(null)); } // check to make sure it's not a system mailing list if (_systemLists.Contains(mailinglist.Name)) { Message = "Unable to edit system mailing list."; // redirect to index return this.RedirectToAction(a => a.Index(mailinglist.Seminar.Id)); } // transfer values AutoMapper.Mapper.Map(mailinglist, existingMailingList); existingMailingList.Seminar = mailinglist.Seminar; // find the ones to delete var peopleToDelete = existingMailingList.People.Where(person => !mailinglist.People.Contains(person)).ToList(); foreach (var person in peopleToDelete) { existingMailingList.People.Remove(person); } // add in the new ones var peopletoAdd = mailinglist.People.Where(a => !existingMailingList.People.Contains(a)).ToList(); foreach (var person in peopletoAdd) { existingMailingList.People.Add(person); } if (ModelState.IsValid) { _mailinglistRepository.EnsurePersistent(existingMailingList); Message = "MailingList Edited Successfully"; return this.RedirectToAction(a => a.Index(mailinglist.Seminar != null ? mailinglist.Seminar.Id : (int?)null)); } var viewModel = MailingListViewModel.Create(RepositoryFactory, Site, mailinglist, mailinglist.Seminar != null ? mailinglist.Seminar.Id : (int?)null); return View(viewModel); }
public ActionResult Create(MailingList mailinglist, int? seminarId) { // make sure it's not a system mailing list if (_systemLists.Contains(mailinglist.Name)) ModelState.AddModelError("Name", "The name is the same as a system defined mailing list."); // make sure one doesn't already exist if (mailinglist.Seminar.MailingLists.Any(a => a.Name == mailinglist.Name)) { ModelState.AddModelError("Name", string.Format("A mailing list with the same name already exists for the {0} seminar.", mailinglist.Seminar.Year)); } if (ModelState.IsValid) { _mailinglistRepository.EnsurePersistent(mailinglist); Message = "MailingList Created Successfully"; //return RedirectToAction("Index"); return this.RedirectToAction(a => a.Index(seminarId)); } var viewModel = MailingListViewModel.Create(RepositoryFactory, Site, mailinglist, seminarId); viewModel.MailingList = mailinglist; return View(viewModel); }
protected void LinkButton3_Click(object sender, EventArgs e) { if (Page.IsValid) { using (var db = drvvv.drvvvSettings.GetDataContextInstance()) { var cMailingLists = db.MailingLists.FirstOrDefault(x => x.SiteID == (int)drvvv.drvvvSettings.GetSite() && x.Email == TextBoxEmailPopUp.Text.Trim()); if (cMailingLists == null) { MailingList inMailingList = new MailingList(); inMailingList.Email = TextBoxEmailPopUp.Text; inMailingList.InDate = DateTime.Now; inMailingList.Lang = 1; inMailingList.Ip = Request.ServerVariables["REMOTE_ADDR"]; inMailingList.SiteID = (int)drvvv.drvvvSettings.GetSite(); db.MailingLists.InsertOnSubmit(inMailingList); db.SubmitChanges(); drvvv.Plugins.PopUpCancel(); Page.RegisterStartupScript("alert", "<script language='javascript'> { alert('נרשמת בהצלחה');}</script>"); } else drvvv.Plugins.PopUpCancel(); } } }
// TODO: move this into MailingRule class static MailingList BuildMailingList(string[] recepients, Dictionary<string, MailingList> groups) { MailingList list = new MailingList(); foreach (var recepient in recepients) { if (groups.ContainsKey(recepient)) // group? { list.UnionWith(groups[recepient]); } else { list.Add(recepient); } } return list; }
partial void DeleteMailingList(MailingList instance);
partial void UpdateMailingList(MailingList instance);
partial void InsertMailingList(MailingList instance);
private void detach_MailingLists(MailingList entity) { this.SendPropertyChanging(); entity.Category = null; }