Example #1
0
 public static void AddNote(string temat, string tresc)
 {
     using (var db = new NoteDbContext())
     {
         var note = new Note
         {
             NoteTime = DateTime.Now,
             Subject  = temat,
             Content  = tresc
         };
         db.Notes.Add(note);
         db.SaveChanges();
     }
 }
Example #2
0
        public static void DeleteNotes(int id)
        {
            using (var db = new NoteDbContext())
            {
                int counter = 1;

                foreach (var note in db.Notes)
                {
                    if (counter == id)
                    {
                        db.Notes.Remove(note);
                        break;
                    }
                    ++counter;
                }
                db.SaveChanges();
            }
        }
Example #3
0
        public static void EditNote(int id, string temat, string tresc)
        {
            using (var db = new NoteDbContext())
            {
                int counter = 1;

                foreach (var note in db.Notes)
                {
                    if (counter == id)
                    {
                        note.NoteTime = DateTime.Now;
                        note.Subject  = temat;
                        note.Content  = tresc;
                        break;
                    }
                    ++counter;
                }
                db.SaveChanges();
            }
        }