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 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)); }
//[WebInvoke(Method = "PUT", UriTemplate = "/{mailingListId}/?provider={provider}")] public MailingListViewModel SaveMailingList(Guid mailingListId, MailingListViewModel mailingList, string provider) { var request = new RestRequest(this.ServiceUrl + "/{mailingListId}/?provider={provider}", Method.PUT); request.AddUrlSegment("mailingListId", mailingListId.ToString()); request.AddUrlSegment("provider", provider); request.AddParameter("application/json", SerializeObject(mailingList), ParameterType.RequestBody); return(ExecuteRequest <MailingListViewModel>(request)); }
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)); }
private void MainWindow_Loaded(object sender, RoutedEventArgs e) { var mlvm = new MailingListViewModel(); mlvm.LoadFromDatabase(); MailingListDockPanel.DataContext = mlvm; var alvm = new AddressListViewModel(); alvm.LoadFromDatabase(); AddressDockPanel.DataContext = alvm; ComposePanel.DataContext = new MessageViewModel(); }
public void MessagePumpTest() { var mlvmTest = new MailingListViewModel(); using (var db = new MailerEntities()) { var mlist = new MailingList { Name = "TestList" }; db.MailingLists.Add(mlist); db.SaveChanges(); var vm = new MailingListItemViewModel(mlist, true); mlvmTest.AddMailingListItemViewModel(vm); vm.Delete(); Assert.IsFalse(mlvmTest.MailingListItemViewModels.Contains(vm)); } }
// // GET: /MailingList/Edit/5 public ActionResult Edit(int id) { var mailinglist = _mailinglistRepository.GetNullableById(id); if (mailinglist == null) { Message = "Unable to locate mailing list."; 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))); } var viewModel = MailingListViewModel.Create(RepositoryFactory, Site, mailinglist, mailinglist.Seminar != null ? mailinglist.Seminar.Id : (int?)null); return(View(viewModel)); }
// // GET: /MailingList/Create public ActionResult Create(int?seminarId) { var viewModel = MailingListViewModel.Create(RepositoryFactory, Site, seminarId: seminarId); return(View(viewModel)); }