public static void ReloadNotes() { if (!IsConnected) { return; } try { notes.Clear(); MyWebService.User myUser = webServiceClient.GetUser(user.Login, user.Password); if (myUser != null) { if (myUser.Admin == true) { foreach (MyWebService.Note note in webServiceClient.GetNotes()) { notes.Add(new Models.Note(note.idNote, note.Title, note.Content, note.Creation, (DateTime)note.LastUpdate)); } } else { foreach (MyWebService.Note note in webServiceClient.GetUserNotes(myUser.idUser)) { notes.Add(new Models.Note(note.idNote, note.Title, note.Content, note.Creation, (DateTime)note.LastUpdate)); } } } else { MessageBox.Show("Veuillez vous identifier pour accéder à vos notes.", "Veuillez vous identifier", MessageBoxButton.OK, MessageBoxImage.Information); } } catch (System.ServiceModel.EndpointNotFoundException e) { MessageBox.Show("Impossible de se connecter au serveur distant. Veuillez reconfigurer les informations du web service !", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void OnAddItem() { if (!IsConnected) { return; } try { MyWebService.User myUser = webServiceClient.GetUser(user.Login, user.Password); Models.Note note = new Models.Note(webServiceClient.GetMaxId() + 1, "Title", ""); webServiceClient.SetNote(webServiceClient.GetMaxId() + 1, myUser.idUser, "Title", ""); notes.Add(note); selectedNote = notes[notes.IndexOf(note)]; } catch (System.ServiceModel.EndpointNotFoundException e) { MessageBox.Show("Impossible de se connecter au serveur distant. Veuillez reconfigurer les informations du web service !", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }