private async Task <bool> LoadMailAsync(int page) { LoggingViewModel.Instance.Information = string.Empty; try { //Clear out any mail added in previous calls to LoadMailAsync() if (MailItems != null) { MailItems.Clear(); } else { MailItems = new ObservableCollection <MailItemViewModel>(); } LoggingViewModel.Instance.Information = "Getting mail ..."; //Get mail from Exchange service via API. var mail = await _mailOperations.GetEmailMessagesAsync(page, _pageSize); if (mail.Count == 0 && _currentPage == 1) { LoggingViewModel.Instance.Information = "You have no mail."; _isLastPage = true; } else if (mail.Count == 0) { LoggingViewModel.Instance.Information = "You have no more mail. Click the \"Get Items\" button to reload the first page."; _isLastPage = true; } else { // Load emails into the observable collection that is bound to UI foreach (var mailItem in mail) { MailItems.Add(new MailItemViewModel(mailItem)); } if (mail.Count < _pageSize) { LoggingViewModel.Instance.Information = String.Format("{0} mail items loaded. Click the \"Get Items\" button to reload the first page.", MailItems.Count); _isLastPage = true; } else { LoggingViewModel.Instance.Information = String.Format("{0} mail items loaded. Click the \"Get Items\" button for more.", MailItems.Count); } } } catch (Exception ex) { LoggingViewModel.Instance.Information = "Error loading mail: " + ex.Message; return(false); } return(true); }
public void UpdateCache() { var items = from a in MailItems where a.OperationFlags.HasFlag(MailOperationFlags.Removing) select a; foreach (var i in items) { MailItems.Remove(i); } }
public void UpdateWorkingItems(IEnumerable <ViewMailItem> items) { foreach (var i in items) { if (i.OperationFlags.HasFlag(MailOperationFlags.Removing)) { MailItems.Remove(i); } i.OperationFlags = MailOperationFlags.None; } }
private void EmailSearchComplete(object sender, EventArgs e) { if (Account.EmailsFound.Count != 0) { MailItems.Clear(); MailItems.AddRange(Account.EmailsFound); } else { MailItems.Add(new Email() { Subject = "No emails detected - review settings" }); } }
/// <summary> /// Sends mail item remove request to the Exchange service. /// </summary> async void ExecuteDeleteMailCommandAsync() { try { if (await MessageDialogHelper.ShowYesNoDialogAsync(String.Format("Are you sure you want to delete the mail item '{0}'?", this._selectedMail.Subject), "Confirm Deletion")) { if (!String.IsNullOrEmpty(this._selectedMail.ID)) { if (await _mailOperations.DeleteMailItemAsync(this._selectedMail.ID)) { //Removes email from bound observable collection MailItems.Remove((MailItemViewModel)_selectedMail); } } } } catch (Exception) { LoggingViewModel.Instance.Information = "We could not delete your mail item."; } }
private void EmailSearchComplete(object sender, EventArgs e) { MailItems.Clear(); MailItems.AddRange(Account.EmailsFound); }
public void Add(IEnumerable <ViewMailItem> items) { MailItems.AddRange(items); Expires = DateTime.Now.AddSeconds(30); }
public void Reset() { MailItems.Clear(); Expires = DateTime.MinValue; }