public async void DeleteNotebook(Notebook notebook) { await DatabaseHelper.Delete(notebook); Notebooks.Remove(notebook); // ReadNotebooks(); }
public async void ReadNotebooks() { //{ // using (SQLite.SQLiteConnection conn = new SQLite.SQLiteConnection(DatabaseHelper.dbFile)) // { // conn.CreateTable<NotebookModel>(); //Make sure the table exists... // var notebooks = conn.Table<NotebookModel>().ToList(); // Notebooks.Clear(); // foreach (var notebook in notebooks) // { // Notebooks.Add(notebook); // } // } try { //Ver que ahora ya sólo leemos los notebooks del usuario que se ha logado... var notebooks = await App.MobileServiceClient.GetTable <NotebookModel>().Where(n => n.UserId == App.UserId).ToListAsync(); Notebooks.Clear(); foreach (var notebook in notebooks) { Notebooks.Add(notebook); } //selectedNotebook= Notebooks.FirstOrDefault(); //weird behavbour } catch (Exception ex) { } }
public async void ReadNotebooks() { #if USEAZURE try { Notebooks.Clear(); var notebooks = await App.MobileServiceClient.GetTable <Notebook>().Where(n => n.UserId == App.UserId).ToListAsync(); foreach (var notebook in notebooks) { Notebooks.Add(notebook); } } catch (Exception ex) { } #else using (SQLiteConnection conn = new SQLiteConnection(DatabaseHelper.dbFile)) { var notebooks = conn.Table <Notebook>().ToList(); Notebooks.Clear(); foreach (var notebook in notebooks) { Notebooks.Add(notebook); } } #endif }
private void OnApplicationUnlocked(ApplicationUnlocked obj) { if (SelectedMenuItem == null) { SelectedItemChangedCommand.Execute(Notebooks.FirstOrDefault()); } }
public void ConfirmNewNotebookName(string newNotebookName) { NewNotebookClicked = false; NotebookModel notebook = Notebooks.ToList <NotebookModel>().Find(n => n.Name == newNotebookName); if (notebook == null) { try { DBDataAccessInsert.InsertNotebook(new NotebookModel() { UserId = User.Id, Name = newNotebookName }); Notebooks.Clear(); Notebooks = new BindableCollection <NotebookModel>(DBDataAccessLoad.LoadNotebooks(User.Id)); } catch (SQLiteException) { MessageBox.Show("Invalid Name"); } } else { MessageBox.Show("Notebook with this name already exists"); } }
public void AddNotebookFromBind(AddNotebookBm bind) { Notebooks notebook = Mapper.Map <AddNotebookBm, Notebooks>(bind); Context.Items.Add(notebook); Context.SaveChanges(); }
private void CreateNotebook(object arg) { MainWindowInstance.ShowInputAsync("Add notebook", "Name:").ContinueWith(delegate(Task <string> task) { string newName = task.Result; if (string.IsNullOrEmpty(newName)) { return; } Notebook nb = new Notebook { Name = newName, Created = DateTime.Now }; nb.Save(); var newNotebook = ViewModelLocator.Instance.GetNotebookViewModel(nb); List <NotebookViewModel> temp = new List <NotebookViewModel>(); temp.AddRange(Notebooks.ToArray()); temp.Add(newNotebook); temp.Sort((x, y) => string.Compare(x.Name, y.Name, StringComparison.Ordinal)); Notebooks.Clear(); temp.ForEach(Notebooks.Add); SelectedNotebook = newNotebook; SelectedNotebook.IsSelected = true; }); }
public async void ReadNoteBooks() { #region Commented Code //using (SQLiteConnection conn = new SQLiteConnection(DatabaseHelper.dbFile)) //{ // conn.CreateTable<NoteBook>(); // //int userid = int.Parse(App.UserId); // var notebooks = conn.Table<NoteBook>().ToList(); // Notebooks.Clear(); // if (notebooks != null) // { // foreach (var notebook in notebooks) // { // Notebooks.Add(notebook); // } // } //} #endregion var notebooks = await App.mobileServiceClient.GetTable <NoteBook>().OrderBy(n => n.Name).ToListAsync(); Notebooks.Clear(); if (notebooks != null) { foreach (var notebook in notebooks) { Notebooks.Add(notebook); } } }
public async void ReadNotebooks() { //using (SQLite.SQLiteConnection conn = new SQLite.SQLiteConnection(DatabaseHelper.GetFileLocation())) //{ // //int userId; // //bool isLogged = int.TryParse(App.UserId, out userId); // var notebooks = conn.Table<Notebook>()/*.Where(n => isLogged && n.UserId == userId)*/.ToList(); // Notebooks.Clear(); // foreach (var notebook in notebooks) // { // Notebooks.Add(notebook); // } //} try { var notebooks = await App.MobileServiceClient.GetTable <Notebook>().Where(n => n.UserId == App.UserId).ToListAsync(); Notebooks.Clear(); foreach (var notebook in notebooks) { Notebooks.Add(notebook); } } catch (Exception ex) { throw ex; } }
public async void ReadNotebooks() { ////using (SQLite.SQLiteConnection conn = new SQLite.SQLiteConnection(DatabaseHelper.dbFile)) ////{ //// var notebooks = conn.Table<Notebook>().ToList(); //// Notebooks.Clear(); //// foreach(var notebook in notebooks) //// { //// Notebooks.Add(notebook); //// } ////} try { var notebooks = await App.MobileServiceClient.GetTable <Notebook>().Where(n => n.UserId == App.UserId).ToListAsync(); Notebooks.Clear(); foreach (var notebook in notebooks) { Notebooks.Add(notebook); } } catch (Exception ex) { } }
private async void NewNotebook() { await App.MobileServiceClient.GetTable <Notebook>().InsertAsync(CreateNewNotebook()); Notebooks.Clear(); ReadNotebooks(); }
public void ReadNotebooks() { using (SQLiteConnection connection = new SQLiteConnection(DataBaseHelper.dbFile)) { var notebooks = connection.Table <Notebook>().ToList(); Notebooks.Clear(); notebooks.ForEach(x => Notebooks.Add(x)); } }
public DetailsNotebookVm GetDetailNotebookVM(int id) { Notebooks notebook = Context.Items.OfType <Notebooks>().FirstOrDefault(book => book.Id == id); DetailsNotebookVm vm = Mapper.Map <Notebooks, DetailsNotebookVm>(notebook); return(vm); }
public void DeleteNotebook(NoteBook noteBook) { if (noteBook != null) { DatabaseHelper.Delete(noteBook); Notebooks.Remove(noteBook); ReadNoteBooks(); } }
public async void ReadNotebooks() { //using (var connection = new SQLite.SQLiteConnection(DatabaseHelper.DatabaseFile)) //{ // try // { // string userId = App.UserId; // if (!string.IsNullOrEmpty(userId)) // { // var notebooks = connection.Table<Notebook>().Where(x => x.UserId == userId).ToList(); // Notebooks.Clear(); // foreach (var notebook in notebooks) // { // Notebooks.Add(notebook); // } // } // else // { // Notebooks.Clear(); // } // } // catch (SQLite.SQLiteException) // { // // TODO logging or information should get shown here? // Notebooks.Clear(); // } //} try { string userId = App.UserId; if (!string.IsNullOrEmpty(userId)) { var notebooks = await App.MobileServiceClient.GetTable <Notebook>().Where(n => n.UserId == userId).ToListAsync(); Notebooks.Clear(); foreach (var notebook in notebooks) { Notebooks.Add(notebook); } PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Notebooks))); } else { Notebooks.Clear(); } } catch (Exception e) { } // Refreshing now ReadNotes(); }
public async void getNotebooks() { var notebooks = (await DatabaseHelper.Read <Notebook>()).Where(n => n.UserId == App.UserId).ToList(); Notebooks.Clear(); foreach (var o in notebooks) { Notebooks.Add(o); } }
public void ReadNotebooks() { var notebooks = DatabaseHelper.Table <Notebook>(); Notebooks.Clear(); foreach (var notebook in notebooks) { Notebooks.Add(notebook); } }
private void GetNotebooks() { var notebooks = DatabaseHelper.Read <Notebook>(); Notebooks.Clear(); foreach (var notebook in notebooks) { Notebooks.Add(notebook); } }
public async Task GetNotebooks() { IEnumerable <Notebook> notebooks = (await DatabaseHelper.Read <Notebook>()).Where(n => n.UserId == App.UserID).ToList(); Notebooks.Clear(); foreach (var notebook in notebooks) { Notebooks.Add(notebook); } }
public void CreateNewNotebook() { Notebook notebook = new Notebook() { Name = "New notebook", Id = int.Parse(App.userID) }; DatabaseHelper.Insert(notebook); Notebooks.Add(notebook); }
private void GetNotebooks() { var notebooks = DatabaseHelper.Read <Notebook>(); Notebooks.Clear(); foreach (var notebook in notebooks) { Notebooks.Add(notebook); //Observable collection a ekleniyor } }
public void Handle(string message) { if (message == "Sign out") { User = null; IsLoggedIn = false; Notes.Clear(); SelectedNotebook = null; Notebooks.Clear(); } }
public NotebookViewModel() { Notebook.Default.Notes.Add(Note.MyScriptNoteDefault); Notebooks.Add(Notebook.Default); Notebook.MyNotebookEn.Notes.Add(Note.ChinaNoteEn); Notebook.MyNotebookEn.Notes.Add(Note.FranceNoteEn); Notebooks.Add(Notebook.MyNotebookEn); Notebook.MyNotebookZh.Notes.Add(Note.ChinaNoteZh); Notebook.MyNotebookZh.Notes.Add(Note.FranceNoteZh); Notebooks.Add(Notebook.MyNotebookZh); }
public async override Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> state) { if (Notebooks.Count == 0) { var notebooks = await NotebooksService.GetNotebooksAsync(); Notebooks.AddRange(notebooks); } await Task.CompletedTask; }
public void ReadNotebooks() { using (SQLite.SQLiteConnection conn = new SQLite.SQLiteConnection(DatabaseHelper.dbFile)) { var notebooks = conn.Table <Notebook>().ToList(); Notebooks.Clear(); foreach (var notebook in notebooks) { Notebooks.Add(notebook); } } }
public async void GetNotebooks() { try { var notebooks = (await Database.Read <Notebook>()).Where(n => n.UserId == App.UserId).ToList(); Notebooks.Clear(); foreach (var notebook in notebooks) { Notebooks.Add(notebook); } } catch (ArgumentNullException) { } }
public void ReadNotebooks() { using (SQLite.SQLiteConnection cn = new SQLite.SQLiteConnection(DatabaseHelper.dbFile)) { var notebooks = cn.Table <Notebook>().ToList(); //TODO: pobieranie notatnikow dla zalogowanego usera Notebooks.Clear(); foreach (var item in notebooks) { Notebooks.Add(item); } } }
public void ReadNotebooks() { using (SQLite.SQLiteConnection connection = new SQLite.SQLiteConnection(DatabaseHelper.dbFile)) { //TODO: handle this exception (When a table of notebook does not exists) var notebooks = connection.Table <Notebook>().ToList(); Notebooks.Clear(); foreach (Notebook notebook in notebooks) { Notebooks.Add(notebook); } SelectedNotebook = Notebooks.FirstOrDefault(); } }
/// <summary> /// Search the notes! A match number of /// <see cref="int.MaxValue"/> indicates that the note /// title contains the search term. /// </summary> /// <param name="query"> /// A <see cref="System.String"/> /// </param> /// <param name="case_sensitive"> /// A <see cref="System.Boolean"/> /// </param> /// <param name="selected_notebook"> /// A <see cref="Notebooks.Notebook"/>. If this is not /// null, only the notes of the specified notebook will /// be searched. /// </param> /// <returns> /// A <see cref="IDictionary`2"/> with the relevant Notes /// and a match number. If the search term is in the title, /// number will be <see cref="int.MaxValue"/>. /// </returns> public IDictionary<Note,int> SearchNotes ( string query, bool case_sensitive, Notebooks.Notebook selected_notebook) { string [] words = Search.SplitWatchingQuotes (query); // Used for matching in the raw note XML string [] encoded_words = SplitWatchingQuotes (XmlEncoder.Encode (query)); Dictionary<Note,int> temp_matches = new Dictionary<Note,int>(); // Skip over notes that are template notes Tag template_tag = TagManager.GetOrCreateSystemTag (TagManager.TemplateNoteSystemTag); foreach (Note note in manager.Notes) { // Skip template notes if (note.ContainsTag (template_tag)) continue; // Skip notes that are not in the // selected notebook if (selected_notebook != null && selected_notebook.ContainsNote (note) == false) continue; // First check the note's title for a match, // if there is no match check the note's raw // XML for at least one match, to avoid // deserializing Buffers unnecessarily. if (0 < FindMatchCountInNote (note.Title, words, case_sensitive)) temp_matches.Add(note,int.MaxValue); else if (CheckNoteHasMatch (note, encoded_words, case_sensitive)){ int match_count = FindMatchCountInNote (note.TextContent, words, case_sensitive); if (match_count > 0) // TODO: Improve note.GetHashCode() temp_matches.Add(note,match_count); } } return temp_matches; }
public void ReadNoteBooks() { using (SQLiteConnection connection = new SQLiteConnection(DatabaseHelper.dbFile)) { //var notebooks = connection.Table<NoteBook>().ToList(); var notebooks = connection.Table <NoteBook>().Where(n => n.UserID == App.UserID).ToList(); Notebooks.Clear(); foreach (var noteBook in notebooks) { Notebooks.Add(noteBook); } } }
public void ReadNotebooks() { // get all Notebooks from the database using (SQLiteConnection connection = new SQLiteConnection(DatabaseHelper.dbFile)) { connection.CreateTable <Notebook>(); var notebooks = connection.Table <Notebook>().ToList(); Notebooks.Clear(); foreach (Notebook nb in notebooks) { Notebooks.Add(nb); } } }
private void OnNoteRemovedFromNotebook (Note note, Notebooks.Notebook notebook) { RestoreMatchesWindow (); UpdateResults (); }
private void OnNoteAddedToNotebook (Note note, Notebooks.Notebook notebook) { RestoreMatchesWindow (); UpdateResults (); }