public async Task LoadAsync() { Friends.Clear(); var lookup = await _friendLookupDataService.GetFriendLookupAsync(); foreach (var friend in lookup) { Friends.Add(new NavigationItemViewModel(friend.Id, friend.DisplayMember, nameof(FriendDetailViewModel), _eventAggregator)); } Meetings.Clear(); lookup = await _meetingLookUpService.GetMeetingLookupAsync(); foreach (var meeting in lookup) { Meetings.Add(new NavigationItemViewModel(meeting.Id, meeting.DisplayMember, nameof(MeetingDetailViewModel), _eventAggregator)); } }
public async Task LoadAsync() { var lookup = await _friendLookupService.GetFrienLookupAsync(); Friends.Clear(); foreach (var item in lookup) { Friends.Add(new NavigationItemViewModel( item.Id, item.DisplayMember, nameof(FriendDetailViewModel), _eventAggregator)); } lookup = await _meetingLookupService.GetMeetingLookupAsync(); Meetings.Clear(); foreach (var item in lookup) { Meetings.Add(new NavigationItemViewModel( item.Id, item.DisplayMember, nameof(MeetingDetailViewModel), _eventAggregator)); } }
/// <summary> /// Refresh today's meetings /// </summary> private void RefreshMeetings() { #if DEBUG var sw = new System.Diagnostics.Stopwatch(); sw.Start(); #endif // Execute the action on the main application thread if (System.Windows.Application.Current != null) { System.Windows.Application.Current.Dispatcher.Invoke(new Action(() => { var selected = SelectedMeeting; Meetings.Clear(); foreach (var client in m_meetingsBL.GetTodaysMeetings().OrderByDescending(m => m.MeetingDate)) { Meetings.Add(client); } if (selected != null) { SelectedMeeting = Meetings.FirstOrDefault(c => c.ClientId == selected.ClientId); } })); } #if DEBUG sw.Stop(); System.Diagnostics.Debug.WriteLine("Refresh meetings List Time: " + sw.ElapsedMilliseconds + "ms"); #endif }
private async Task LoadNavigationMeetings() { var meetingsLookupServiceCall = await this._meetingService .GetAllAsync(); Meetings.Clear(); foreach (var meeting in meetingsLookupServiceCall) { Meetings.Add( new NavigationViewItemModel( meeting.Id, meeting.Title, this._eventAggregator, nameof(MeetingDetailViewModel))); } }
public async Task LoadAsync() { // LOAD Friends var lookup = await _friendLookupService.GetFriendLookupAsync(); Friends.Clear(); // To be sure to call this async method multiple times, clear befoere look again over recived friends foreach (var item in lookup) { Friends.Add(new NavigationItemViewModel(item.Id, item.DisplayMember, nameof(FriendDetailViewModel), _eventAggregator)); } // LOAD Meetings lookup = await _meetingLookupService.GetMeetingLookupAsync(); Meetings.Clear(); foreach (var item in lookup) { Meetings.Add(new NavigationItemViewModel(item.Id, item.DisplayMember, nameof(MeetingDetailViewModel), _eventAggregator)); } }
private async Task RefreshMeetings(bool forceRefresh, CancellationToken token) { IsBusy = true; try { Meetings.PauseNotifications(); //var test = App.Instance.GetInstance<IUseFullDocumentService>(); //var documents = await test.GetDocumentsAsync(); var meetings = await _meetingService.GetMeetingsAsync(forceRefresh, token); Meetings.Clear(); Meetings.AddRange(meetings); var lastUpdate = _meetingService.GetLastUpdateTime(); UpdateLastUpdateText(lastUpdate); } catch (TaskCanceledException ex) { Debug.WriteLine(ex.Message); } catch (TokenExpiredException ex) { Debug.WriteLine(ex.Message); this.ShowViewModel <StartupViewModel>(); } catch (System.Exception ex) { Debug.WriteLine(ex.Message); await App.Instance.AlertService.ShowExceptionMessageAsync(ex, "Erreur lors de la récupération des rendez-vous."); } finally { _pageTokenSource = null; Meetings.ResumeNotifications(); IsBusy = false; } }
private async Task RefreshMeetings(bool forceRefresh) { IsBusy = true; try { Meetings.PauseNotifications(); var meetings = await _meetingService.GetMeetingsAsync(forceRefresh, CancellationToken.None); Meetings.Clear(); var flatMeetings = new List <MeetingViewModel>(); foreach (var meeting in meetings) { var currentDate = meeting.StartDate; while (currentDate < meeting.EndDate) { flatMeetings.Add(new MeetingViewModel(meeting, currentDate)); currentDate = currentDate.AddDays(1); } } var groupedMeetings = flatMeetings.GroupBy(m => m.Date). ToDictionary(m => m.Key, m => m.ToList()); var finalDate = DateTime.Now.Date.AddMonths(4); var currentGroupedDate = DateTime.Now.Date; while (currentGroupedDate <= finalDate) { if (groupedMeetings.ContainsKey(currentGroupedDate)) { var currentGroup = groupedMeetings[currentGroupedDate]; Meetings.Add(new GroupedMeetingViewModel(currentGroupedDate, currentGroup.ToList())); } else { var noMeeting = new Meeting(); noMeeting.AllDayEvent = true; noMeeting.EndDate = currentGroupedDate; noMeeting.StartDate = currentGroupedDate; // TODO : localisation noMeeting.Title = "Aucun événement"; noMeeting.Type = MeetingType.Unknown; var noMeetings = new List <MeetingViewModel>(); noMeetings.Add(new MeetingViewModel(noMeeting, currentGroupedDate)); Meetings.Add(new GroupedMeetingViewModel(currentGroupedDate, noMeetings)); } currentGroupedDate = currentGroupedDate.AddDays(1); } _lastUpdate = _meetingService.GetLastUpdateTime(); RaisePropertyChanged(nameof(Meetings)); RaisePropertyChanged(nameof(LastUpdate)); } catch (System.Exception ex) { await Mvx.Resolve <IMessageService>() .ShowErrorToastAsync(ex, "Erreur lors de la récupération des rendez-vous."); } finally { Meetings.ResumeNotifications(); IsBusy = false; } }