Пример #1
0
        public static List <Note> NoteList2()
        {
            using (var db = new NoteDbContext())
            {
                List <Note> Notes = new List <Note>();

                foreach (var note in db.Notes)
                {
                    Notes.Add(note);
                }
                return(Notes);
            }
        }
Пример #2
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();
     }
 }
Пример #3
0
        public static List <String> NoteList()
        {
            using (var db = new NoteDbContext())
            {
                List <String> Notes = new List <String>();

                foreach (var note in db.Notes)
                {
                    string temp, date;
                    date = note.NoteTime.ToShortDateString();
                    temp = "Data dodania: " + date + ", " + note.Subject + ": " + note.Content;
                    Notes.Add(temp);
                }
                return(Notes);
            }
        }
Пример #4
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();
            }
        }
Пример #5
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();
            }
        }