private async void SaveNote(object obj) { IsReadOnly = true; IsSaveButtonVisible = Visibility.Hidden; IsEditButtonVisible = Visibility.Visible; AuthenticationToken authToken = new AuthenticationToken(ConnectionApi.HttpClient); token = await authToken.PostAuthRecordAsync(_authenticationRecord); user = await methods.GetUserInfo(token, _authenticationRecord.Email); noteApi = new NoteApi(_authenticationRecord, user.Id); noteApi.UpdateNoteAsync(Note.Id, Note); OnPropertyChanged(nameof(IsSaveButtonVisible)); OnPropertyChanged(nameof(IsSaveButtonVisible)); OnPropertyChanged(nameof(IsReadOnly)); }
public async void GetAllNotes(bool showSingleNotes) { getToken(); LoggedUser = await methods.GetUserInfo(token, _authenticationRecord.Email); noteApi = new NoteApi(_authenticationRecord, LoggedUser.Id); try { IEnumerable <Note> tempNotes = await noteApi.GetAllNotesAsync(); IEnumerable <Note> tempSortedNotes = tempNotes.OrderByDescending <Note, DateTime>(o => o.CreateTimestamp).ToList(); Notes.Clear(); singleNotes.Clear(); foreach (var note in tempSortedNotes) { Notes.Add(note); singleNotes.Add(note); } foreach (var note in Notes) { note.CreateTimestamp = note.CreateTimestamp.ToLocalTime(); note.LastChangeTimestamp = note.LastChangeTimestamp.ToLocalTime(); if (showSingleNotes == true) { var window = new SingleNoteWindow(note); window.Show(); singleNoteWindows.Add(window); } } } catch (Exception e) { MessageBox.Show("An error has occured." + e.Message); return; } }