public TEXTNOTE insertTextNote(TEXTNOTE newTEXTNOTE)
        {
            TEXTNOTE newTextNote = myModel.TEXTNOTEs.Add(newTEXTNOTE);

            myModel.SaveChanges();

            changeUI_Note();

            return(newTextNote);
        }
 public void assignTextNote(TEXTNOTE newNote)
 {
     this.IdNote = newNote.IdNote;
     this.mTitle = newNote.mTitle;
     if (newNote.mContent != null)
     {
         this.mContent = newNote.mContent.Clone().ToString();
     }
     this.mAccessTime = newNote.mAccessTime;
 }
        //public List<TEXTNOTE> getPreviewAllTextNote()
        //{
        //    List<TEXTNOTE> listTextNote = new List<TEXTNOTE>();
        //    DbSet<TAG> listTags = myModel.TAGs;

        //    foreach (TAG tag in listTags)
        //    {
        //        listTextNote.Concat<TEXTNOTE>(tag.getAllPreviewTextNote());
        //    }

        //    return listTextNote;
        //}

        public TEXTNOTE findNoteByID(int id)
        {
            TEXTNOTE         result = null;
            DbSet <TEXTNOTE> dbNote = myModel.TEXTNOTEs;

            foreach (TEXTNOTE note in dbNote)
            {
                if (note.IdNote == id)
                {
                    result = note;
                    break;
                }
            }
            return(result);
        }
        public TEXTNOTE getTextNoteByID(TEXTNOTE textNote)
        {
            if (textNote == null)
            {
                return(null);
            }

            DbSet <TEXTNOTE> listTextNotes = myModel.TEXTNOTEs;

            var selectNote = (from note in listTextNotes
                              where note.IdNote == textNote.IdNote
                              select note);

            var firstNote = selectNote.First();

            return(firstNote);
        }
        public bool modifyTextNote(TEXTNOTE modifiedTextNote, TEXTNOTE newTextNote)
        {
            DbSet <TEXTNOTE> listTextNotes = myModel.TEXTNOTEs;
            bool             flagReturn    = false;

            var textNote = (from note in listTextNotes
                            where note.IdNote == modifiedTextNote.IdNote
                            select note).FirstOrDefault <TEXTNOTE>();

            if (textNote != null)
            {
                textNote.assignTextNote(newTextNote);
                flagReturn = true;
            }

            // Change UI
            myModel.SaveChanges();

            changeUI_Note();

            return(flagReturn);
        }
        public bool removeTextNote(TEXTNOTE removedTEXTNOTE)
        {
            DbSet <TEXTNOTE> listTextNotes = myModel.TEXTNOTEs;
            bool             flagReturn    = false;

            var textNote = (from note in listTextNotes
                            where note.IdNote == removedTEXTNOTE.IdNote
                            select note).FirstOrDefault <TEXTNOTE>();

            // Delete it from memory.
            if (textNote != null)
            {
                myModel.TEXTNOTEs.Remove(textNote);
                flagReturn = true;
            }

            // Change UI
            myModel.SaveChanges();

            changeUI_Note();

            return(flagReturn);
        }
 public void saveChangeTextNote(TEXTNOTE curNote, TEXTNOTE newNote)
 {
     curNote.assignTextNote(newNote);
 }