private async void btnEnviar_Clicked(object sender, System.EventArgs e) { bool bErro = false; string sErro = string.Empty; using (UserDialogs.Instance.Loading("Enviando...")) { var lst = Valida(out sErro); if (lst == null) { bErro = true; } else { await NotificationService.SendNotification(lst); } } if (bErro) { await App.Current.MainPage.DisplayAlert("Nada foi enviado", sErro, "OK"); return; } await App.Current.MainPage.DisplayAlert("Sucesso", "Notificações enviadas!", "OK"); vm = new SendNotificationViewModel(); // reinicia campos pcTipo.SelectedItem = null; txtText.Text = ""; BindingContext = vm; }
/// <summary> /// Standard class constructor /// </summary> public FileListViewModel() { _ParsedFilter = this.GetParsedFilters(_FilterString); BookmarkFolder = new EditFolderBookmarks(); Notification = new SendNotificationViewModel(); _CurrentItems = new ObservableCollection <ILVItemViewModel>(); }
public ActionResult Send(List <int> people, NotificationTracking notificationTracking, EmailQueue emailQueue, int?mailingListId, int[] attachmentIds) { if ((people == null || people.Count <= 0) && !mailingListId.HasValue) { ModelState.AddModelError("People", "No person has been selected to receive the notification."); } var tracking = new List <NotificationTracking>(); ModelState.Clear(); notificationTracking.TransferValidationMessagesTo(ModelState); if (string.IsNullOrWhiteSpace(emailQueue.Subject)) { ModelState.AddModelError("EmailQueue.Subject", "You must enter a subject."); } var mailingList = mailingListId.HasValue ? Repository.OfType <MailingList>().GetNullableById(mailingListId.Value) : null; // save the objects if we are good if (ModelState.IsValid) { tracking = ProcessTracking(ModelState, people, notificationTracking, attachmentIds, emailQueue, mailingList); foreach (var a in tracking) { _notificationTrackingRepository.EnsurePersistent(a); } Message = string.Format(Messages.Saved, "Notification tracking"); if (tracking.Count == 1 && !mailingListId.HasValue) { var person = tracking[0].Person; var url = Url.Action("AdminEdit", "Person", new { id = person.User.Id, seminarId = SiteService.GetLatestSeminar(Site).Id }); return(Redirect(string.Format("{0}#notifications", url))); } // redirect back to the seminar controller details return(this.RedirectToAction <SeminarController>(a => a.Details(null))); } // not good, hand the page back var ntViewModel = NotificationTrackingViewModel.Create(Repository, Site, notificationTracking, mailingList: mailingList); ntViewModel.People = tracking.Select(a => a.Person).ToList(); var viewModel = SendNotificationViewModel.Create(Repository, ntViewModel, emailQueue); return(View(viewModel)); }
/// <summary> /// Sending a notification through this program /// </summary> /// <returns></returns> public ActionResult Send(int?personId) { Person person = null; if (personId.HasValue) { person = _personRepository.GetNullableById(personId.Value); } var ntViewModel = NotificationTrackingViewModel.Create(Repository, Site, person: person); ntViewModel.NotificationTracking.NotifiedBy = CurrentUser.Identity.Name; ntViewModel.NotificationTracking.Seminar = SiteService.GetLatestSeminar(Site); ntViewModel.NotificationTracking.NotificationMethod = _notificationMethodRepository.GetById(StaticIndexes.NotificationMethod_Email); var viewModel = SendNotificationViewModel.Create(Repository, ntViewModel); return(View(viewModel)); }
/// <summary> /// Standard class constructor /// </summary> protected FileListViewModel() { BookmarkFolder = new EditFolderBookmarks(); Notification = new SendNotificationViewModel(); _CurrentItems = new ObservableCollection <ILVItemViewModel>(); }
public ActionResult SendNotification(SendNotificationViewModel model) { try { if (!ModelState.IsValid) { return(View()); } HttpCookie conString = Request.Cookies.Get("rwxgqlb"); Notification n = null; try { n = new Notification(model.Body, DateTime.Now, model.Status, model.Type, Cryptography.Decrypt(conString.Value)); } catch (Exception ex) { ModelState.AddModelError(string.Empty, ex.Message); return(View()); } if (model.Status == NotificationStatuses.ForParent) { List <int> lstParentIds = model.Parents.ToList(); Parent p; foreach (var item in lstParentIds) { p = new Parent(item, Cryptography.Decrypt(conString.Value)); p.SendNotification(n); } } else if (model.Status == NotificationStatuses.ForTeacher) { List <int> lstTeacherIds = model.Teachers.ToList(); Teacher t; foreach (var item in lstTeacherIds) { t = new Teacher(item, Cryptography.Decrypt(conString.Value)); } } else if (model.Status == NotificationStatuses.ForAll) { List <int> lstParentIds = model.Parents.ToList(); Parent p; foreach (var item in lstParentIds) { p = new Parent(item, Cryptography.Decrypt(conString.Value)); p.SendNotification(n); } List <int> lstTeacherIds = model.Teachers.ToList(); Teacher t; foreach (var item in lstTeacherIds) { t = new Teacher(item, Cryptography.Decrypt(conString.Value)); } } return(RedirectToAction("SendNotification", new { s = true })); } catch (Exception ex) { return(Content(ex.Message)); } }
public SendNotificationPage() { vm = new SendNotificationViewModel(); BindingContext = vm; InitializeComponent(); }