Ejemplo n.º 1
0
 public Note[] GetNotes()
 {
     using (var ctx = new DataModel())
     {
         return ctx.Notes.ToArray().Select(NoteConverter.FromModel).ToArray();
     }
 }
Ejemplo n.º 2
0
 public Operation[] GetHistory()
 {
     using (var ctx = new DataModel())
     {
         return ctx.Operations.ToArray().Select(OperationConverter.FromModel).ToArray();
     }
 }
Ejemplo n.º 3
0
 private void AddToHistory(Operation operation)
 {
     using (var ctx = new DataModel())
     {
         ctx.Operations.Add(OperationConverter.ToModel(operation));
         ctx.SaveChanges();
     }
 }
Ejemplo n.º 4
0
 private void AddNote(Note note)
 {
     using (var ctx = new DataModel())
     {
         ctx.Notes.Add(NoteConverter.ToModel(note));
         ctx.SaveChanges();
     }
 }
Ejemplo n.º 5
0
        public void DeleteNote(string id)
        {
            int noteId = Convert.ToInt32(id);

            using (var ctx = new DataModel())
            {
                NoteModel note = ctx.Notes.SingleOrDefault(b => b.Id == noteId);
                if (note != null)
                {
                    ctx.Notes.Remove(note);
                    ctx.SaveChanges();
                }
            }
        }
Ejemplo n.º 6
0
        public void UpdateNote(string id, string titre, string description)
        {
            int noteId = Convert.ToInt32(id);

            using (var ctx = new DataModel())
            {
                NoteModel note =  ctx.Notes.SingleOrDefault(b => b.Id == noteId);
                if (note == null)
                {
                    note = new NoteModel();
                }
                note.Titre = titre;
                note.Description = description;
                ctx.SaveChanges();
            }
        }