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>
        /// 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();
            }
        }