Exemple #1
0
        /// <summary>
        /// Asynchronously inserts a new note into the database.
        /// </summary>
        public static async void InsertNoteAsync(Note note)
        {
            using (var db = new NotesContext())
            {
                // If the database contains the note, do not insert it again
                // Example: we take a note out of the database, then try to insert it again

                if (note.Id != 0 && db.Notes.Select(x => x.Id == note.Id).Count() == 0)
                {
                    db.Notes.Add(note);
                    await db.SaveChangesAsync();
                }
            }
        }