Exemplo n.º 1
0
 /// <summary>
 /// Remove note
 /// </summary>
 /// <param name="note"></param>
 public void RemoveNote(Note note)
 {
     using (NoterDbContext ctx = this.dbConnector.GetContext())
     {
         ctx.Entry(note).State = System.Data.Entity.EntityState.Deleted;
         ctx.SaveChanges();
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Set note by ArchivedEnum
        /// </summary>
        /// <param name="note"></param>
        /// <param name="type"></param>
        public void SetArchived(Note note, ArchivedEnum type)
        {
            using (NoterDbContext db = this.dbConnector.GetContext())
            {
                note.Archived        = type;
                db.Entry(note).State = System.Data.Entity.EntityState.Modified;

                db.SaveChanges();
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Clear local notes and load database
 /// </summary>
 public void RefreshNotes()
 {
     this.Notes.Clear();
     using (NoterDbContext ctx = this.dbConnector.GetContext())
     {
         foreach (Note note in ctx.Notes)
         {
             this.Notes.Add(note);
         }
     }
 }
Exemplo n.º 4
0
 /// <summary>
 /// Fill Notes by ArchivedEnum
 /// </summary>
 /// <param name="type"></param>
 public void RefreshNotes(ArchivedEnum type)
 {
     this.Notes.Clear();
     using (NoterDbContext ctx = this.dbConnector.GetContext())
     {
         foreach (Note note in ctx.Notes)
         {
             if (note.Archived.Equals(type))
             {
                 this.Notes.Add(note);
             }
         }
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// Save or Edit note and save changes to database
        /// </summary>
        public void SaveChanges()
        {
            using (NoterDbContext db = this.connector.GetContext())
            {
                if (this.note != null)
                {
                    this.note.Name            = this.Name;
                    this.note.Text            = this.Text;
                    this.note.Priority        = this.Priority;
                    this.note.Edited          = DateTime.Now.ToString(Note.DateTimeFormat);
                    db.Entry(this.note).State = System.Data.Entity.EntityState.Modified;
                }
                else
                {
                    Note newNote = new Note(this.Name, this.Text, this.Priority);
                    db.Notes.Add(newNote);
                }

                db.SaveChanges();
            }
        }