Esempio n. 1
0
        private void StickyNoteListBox_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            StickyNote     Note       = StickyNoteListBox.SelectedItem as StickyNote;
            StickyNoteForm stickyForm = new StickyNoteForm();

            stickyForm.NewStickyNote = Note;

            if ((bool)stickyForm.ShowDialog())
            {
                if (!Note.Same(stickyForm.NewStickyNote))
                {
                    StickyNoteListBox.Items.Remove(Note);
                    using (var Ctx = new Context())
                    {
                        Note.Update(stickyForm.NewStickyNote);
                        Ctx.Entry(Note).State = System.Data.Entity.EntityState.Modified;
                        Ctx.SaveChanges();
                    }
                    StickyNoteListBox.Items.Add(Note);
                }
            }

            else
            {
                StickyNoteListBox.Items.Remove(Note);
                //delete data data base
                using (var Ctx = new Context())
                {
                    Ctx.Entry(Note).State = System.Data.Entity.EntityState.Deleted;
                    Ctx.SaveChanges();
                }
            }
        }
Esempio n. 2
0
        public void UpdatAndSameTest()
        {
            StickyNote note = new StickyNote();

            note.Title   = "testTitle";
            note.Content = "testContext";

            StickyNote mainNote = new StickyNote();

            mainNote.Title   = "mainTitle";
            mainNote.Content = "mainContext";

            Assert.IsFalse(note.Same(mainNote));

            note.Update(mainNote);

            Assert.IsTrue(note.Same(mainNote));
        }