示例#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();
            }
        }