Пример #1
0
        private void workerDeleteNote_DoWork(object sender, DoWorkEventArgs e)
        {
            var note = e.Argument as Note;

            _noteManager.Delete(note);
            e.Result = note;
        }
Пример #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            Note note = noteManager.Find(x => x.Id == id);

            noteManager.Delete(note);
            return(RedirectToAction("Index"));
        }
Пример #3
0
        /// <summary>
        /// Prompt the user and delete the notebok (if they say so).
        /// </summary>
        /// <param name="parent">
        /// A <see cref="Gtk.Window"/>
        /// </param>
        /// <param name="notebook">
        /// A <see cref="Notebook"/>
        /// </param>
        public static void PromptDeleteNotebook(Gtk.Window parent, Notebook notebook)
        {
            // Confirmation Dialog
            HIGMessageDialog dialog =
                new HIGMessageDialog(parent,
                                     Gtk.DialogFlags.Modal,
                                     Gtk.MessageType.Question,
                                     Gtk.ButtonsType.YesNo,
                                     Catalog.GetString("Really delete this notebook?"),
                                     Catalog.GetString(
                                         "The notes that belong to this notebook will not be " +
                                         "deleted, but they will no longer be associated with " +
                                         "this notebook.  This action cannot be undone."));

            dialog.DefaultResponse = Gtk.ResponseType.No;
            int response = dialog.Run();

            dialog.Destroy();
            if (response != (int)Gtk.ResponseType.Yes)
            {
                return;
            }

            DeleteNotebook(notebook);

            // Delete the template note
            Note templateNote = notebook.GetTemplateNote();

            if (templateNote != null)
            {
                NoteManager noteManager = Tomboy.DefaultNoteManager;
                noteManager.Delete(templateNote);
            }
        }
Пример #4
0
        public ActionResult NDeleteConfirmed(int id)
        {
            UnNotes notes = noteManager.Find(x => x.Id == id);

            noteManager.Delete(notes);
            return(RedirectToAction("Note"));
        }
Пример #5
0
        // GET: Cleaner
        public string CleanNotes()
        {
            NoteManager    nm = new NoteManager();
            LikedManager   lm = new LikedManager();
            CommentManager cm = new CommentManager();

            DateTime minDate = DateTime.Now.AddMinutes(-2);

            // 2 dk dan eski notlar bulunur.
            List <Note> toDeleteNotes = nm.List(x => x.CreatedOn < minDate && x.IsDeletedNote);

            // Notun like ve comment'leri silinir..
            toDeleteNotes.ForEach(x =>
            {
                foreach (Comment com in x.Commnets.ToList())
                {
                    cm.Delete(com);
                }

                foreach (Liked liked in x.Likes.ToList())
                {
                    lm.Delete(liked);
                }
            });

            // Notlar silinir.
            foreach (Note note in toDeleteNotes)
            {
                nm.Delete(note);
            }

            return("ok");
        }
Пример #6
0
        public ActionResult DeleteConfirmed(int Id)
        {
            _note = nm.Find(x => x.Id == Id);
            nm.Delete(_note);

            return(RedirectToAction("Index"));
        }
        public override int Delete(Category category)
        {
            NoteManager    noteManager    = new NoteManager();
            LikedManager   likedManager   = new LikedManager();
            CommentManager commentManager = new CommentManager();

            // Kategori ile ilişkili notların silinmesi gerekiyor.
            foreach (Note note in category.Notes.ToList())
            {
                // Note ile ilişikili like'ların silinmesi.
                foreach (Liked like in note.Likes.ToList())
                {
                    likedManager.Delete(like);
                }

                // Note ile ilişkili comment'lerin silinmesi
                foreach (Comment comment in note.Comments.ToList())
                {
                    commentManager.Delete(comment);
                }

                noteManager.Delete(note);
            }

            return(base.Delete(category));
        }
Пример #8
0
        public override int Delete(Category category)
        {
            NoteManager noteManager = new NoteManager();

//TODO:            //LikedManager likedManager = new LikedManager();
            //CommentManager commentManager = new CommentManager();


            foreach (Note note in category.Notes.ToList())
            {
                foreach (Liked like in note.Likes.ToList())
                {
                    //TODO:    likedManager.Delete(like);
                }
                foreach (Comment comment in note.Comments.ToList())
                {
                    //TODO:  commentManager.Delete(comment);
                }



                noteManager.Delete(note);
            }



            return(base.Delete(category));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            Note note = _noteManager.Get(x => x.Id == id);
            BussinessResult <Note> result = null;

            // TODO : Check And Remove

            if (note != null)
            {
                foreach (Liked like in note.Likes)
                {
                    _likeManager.Delete(like);
                }
                foreach (Comment comment in note.Comments)
                {
                    _commentManager.Delete(comment);
                }
                result = _noteManager.Delete(note);
            }


            if (result.Errors.Count > 0)
            {
                foreach (BussinessError error in result.Errors)
                {
                    ModelState.AddModelError("", error.Detail);
                }
                return(View(note));
            }

            TempData["NoteDelete"] = result.Successes;
            return(RedirectToAction("Index"));
        }
        public override int Delete(Category category)
        {
            NoteManager    noteManager    = new NoteManager();
            LikedManager   likedManager   = new LikedManager();
            CommentManager commentManager = new CommentManager();

            //Kategori ile bağlantılı notlar silinecek
            foreach (Note note in category.Notes.ToList())
            {
                //Not ile ilişkili beğeniler silinecek
                foreach (Liked like in note.Likes.ToList())
                {
                    likedManager.Delete(like);
                }

                foreach (Comment comment in note.Comments.ToList())
                {
                    commentManager.Delete(comment);
                }


                noteManager.Delete(note);
            }

            return(base.Delete(category));
        }
Пример #11
0
        public async Task <IActionResult> DeleteNote(int id)
        {
            Note note = await noteManager.GetNote(id);

            await noteManager.Delete(note);

            return(Ok());
        }
 public bool DeleteNote(int userId, Note note)
 {
     bool result = false;
     using (NoteManager manager = new NoteManager())
     {
         if (manager.ValidateNoteOwner(userId, note.Id))
             result = manager.Delete(note.Id);
     }
     return result;
 }
 private void btnDelete_Click(object sender, EventArgs e)
 {
     if (txtId.Text != "" || txtId.Text == null)
     {
         var id = Convert.ToInt32(txtId.Text);
         noteManager.Delete(id);
         MessageBox.Show("Not Başarıyla Silindi.");
         ShowAllData();
     }
 }
Пример #14
0
 public void NoteConflictDetected(NoteManager manager, Note localConflictNote, NoteUpdate remoteNote, IList <string> noteUpdateTitles)
 {
     Logger.Debug("SilentUI: NoteConflictDetected, overwriting without a care");
     // TODO: At least respect conflict prefs
     // TODO: Implement more useful conflict handling
     if (localConflictNote.Id != remoteNote.UUID)
     {
         manager.Delete(localConflictNote);
     }
     SyncManager.ResolveConflict(SyncTitleConflictResolution.OverwriteExisting);
 }
Пример #15
0
        public override int Delete(Category category)
        {
            foreach (Note notes in category.Notes.ToList())
            {
                foreach (Liked likes in notes.Likes.ToList())
                {
                    likeManager.Delete(likes);
                }

                foreach (Comment comment in notes.Comments.ToList())
                {
                    commentManager.Delete(comment);
                }

                noteManager.Delete(notes);
            }
            return(base.Delete(category));
        }
Пример #16
0
        public static void CleanupOld(NoteManager manager)
        {
            List<Note> kill_list = new List<Note> ();
            DateTime date_today = DateTime.Today; // time set to 00:00:00

            foreach (Note note in manager.Notes) {
                if (note.Title.StartsWith (title_prefix) &&
                                note.Title != TemplateTitle &&
                                note.CreateDate.Date != date_today &&
                                !HasChanged (note)) {
                    kill_list.Add (note);
                }
            }

            foreach (Note note in kill_list) {
                Logger.Debug ("NoteOfTheDay: Deleting old unmodified '{0}'",
                            note.Title);
                manager.Delete (note);
            }
        }
Пример #17
0
        public static void CleanupOld(NoteManager manager)
        {
            List <Note> kill_list  = new List <Note> ();
            DateTime    date_today = DateTime.Today;          // time set to 00:00:00

            foreach (Note note in manager.Notes)
            {
                if (note.Title.StartsWith(title_prefix) &&
                    note.Title != TemplateTitle &&
                    note.CreateDate.Date != date_today &&
                    !HasChanged(note))
                {
                    kill_list.Add(note);
                }
            }

            foreach (Note note in kill_list)
            {
                Logger.Debug("NoteOfTheDay: Deleting old unmodified '{0}'",
                             note.Title);
                manager.Delete(note);
            }
        }
Пример #18
0
        public override int Delete(Category category)
        {
            NoteManager    noteManager    = new NoteManager();
            LikedManager   likedManager   = new LikedManager();
            CommentManager commentManager = new CommentManager();

            foreach (var note in category.Notes.ToList())
            {
                foreach (var liked in note.Likeds.ToList())
                {
                    likedManager.Delete(liked);
                }

                foreach (var comment in note.Comments.ToList())
                {
                    commentManager.Delete(comment);
                }

                noteManager.Delete(note);
            }

            return(base.Delete(category));
        }
Пример #19
0
		public void NoteConflictDetected (NoteManager manager, Note localConflictNote, NoteUpdate remoteNote, IList<string> noteUpdateTitles)
		{
			Logger.Debug ("SilentUI: NoteConflictDetected, overwriting without a care");
			// TODO: At least respect conflict prefs
			// TODO: Implement more useful conflict handling
			if (localConflictNote.Id != remoteNote.UUID)
				GuiUtils.GtkInvokeAndWait (() => {
					manager.Delete (localConflictNote);
				});
			SyncManager.ResolveConflict (SyncTitleConflictResolution.OverwriteExisting);
		}
Пример #20
0
		public void NoteConflictDetected (NoteManager manager,
		                             Note localConflictNote,
		                             NoteUpdate remoteNote,
		                             IList<string> noteUpdateTitles)
		{
			SyncTitleConflictResolution savedBehavior = SyncTitleConflictResolution.Cancel;
			object dlgBehaviorPref = Preferences.Get (Preferences.SYNC_CONFIGURED_CONFLICT_BEHAVIOR);
			if (dlgBehaviorPref != null && dlgBehaviorPref is int) // TODO: Check range of this int
				savedBehavior = (SyncTitleConflictResolution)dlgBehaviorPref;

			SyncTitleConflictResolution resolution = SyncTitleConflictResolution.OverwriteExisting;
			// This event handler will be called by the synchronization thread
			// so we have to use the delegate here to manipulate the GUI.
			// To be consistent, any exceptions in the delgate will be caught
			// and then rethrown in the synchronization thread.
			Exception mainThreadException = null;
			Gtk.Application.Invoke (delegate {
				try {
					SyncTitleConflictDialog conflictDlg =
					new SyncTitleConflictDialog (localConflictNote, noteUpdateTitles);
					Gtk.ResponseType reponse = Gtk.ResponseType.Ok;

					bool noteSyncBitsMatch =
					        SyncManager.SynchronizedNoteXmlMatches (localConflictNote.GetCompleteNoteXml (),
					                                                remoteNote.XmlContent);

					// If the synchronized note content is in conflict
					// and there is no saved conflict handling behavior, show the dialog
					if (!noteSyncBitsMatch && savedBehavior == 0)
						reponse = (Gtk.ResponseType) conflictDlg.Run ();


					if (reponse == Gtk.ResponseType.Cancel)
						resolution = SyncTitleConflictResolution.Cancel;
					else {
						if (noteSyncBitsMatch)
							resolution = SyncTitleConflictResolution.OverwriteExisting;
						else if (savedBehavior == 0)
							resolution = conflictDlg.Resolution;
						else
							resolution = savedBehavior;

						switch (resolution) {
						case SyncTitleConflictResolution.OverwriteExisting:
							if (conflictDlg.AlwaysPerformThisAction)
								savedBehavior = resolution;
							// No need to delete if sync will overwrite
							if (localConflictNote.Id != remoteNote.UUID)
								manager.Delete (localConflictNote);
							break;
						case SyncTitleConflictResolution.RenameExistingAndUpdate:
							if (conflictDlg.AlwaysPerformThisAction)
								savedBehavior = resolution;
							RenameNote (localConflictNote, conflictDlg.RenamedTitle, true);
							break;
						case SyncTitleConflictResolution.RenameExistingNoUpdate:
							if (conflictDlg.AlwaysPerformThisAction)
								savedBehavior = resolution;
							RenameNote (localConflictNote, conflictDlg.RenamedTitle, false);
							break;
						}
					}

					Preferences.Set (Preferences.SYNC_CONFIGURED_CONFLICT_BEHAVIOR,
					                 (int) savedBehavior); // TODO: Clean up

					conflictDlg.Hide ();
					conflictDlg.Destroy ();

					// Let the SyncManager continue
					SyncManager.ResolveConflict (/*localConflictNote, */resolution);
				} catch (Exception e) {
					mainThreadException = e;
				}
			});
			if (mainThreadException != null)
				throw mainThreadException;
		}
Пример #21
0
        public void NoteConflictDetected(NoteManager manager,
                                         Note localConflictNote,
                                         NoteUpdate remoteNote,
                                         IList <string> noteUpdateTitles)
        {
            SyncTitleConflictResolution savedBehavior = SyncTitleConflictResolution.Cancel;
            object dlgBehaviorPref = Preferences.Get(Preferences.SYNC_CONFIGURED_CONFLICT_BEHAVIOR);

            if (dlgBehaviorPref != null && dlgBehaviorPref is int)             // TODO: Check range of this int
            {
                savedBehavior = (SyncTitleConflictResolution)dlgBehaviorPref;
            }

            SyncTitleConflictResolution resolution = SyncTitleConflictResolution.OverwriteExisting;
            // This event handler will be called by the synchronization thread
            // so we have to use the delegate here to manipulate the GUI.
            // To be consistent, any exceptions in the delgate will be caught
            // and then rethrown in the synchronization thread.
            Exception mainThreadException = null;

            Gtk.Application.Invoke(delegate {
                try {
                    SyncTitleConflictDialog conflictDlg =
                        new SyncTitleConflictDialog(localConflictNote, noteUpdateTitles);
                    Gtk.ResponseType reponse = Gtk.ResponseType.Ok;

                    bool noteSyncBitsMatch =
                        SyncManager.SynchronizedNoteXmlMatches(localConflictNote.GetCompleteNoteXml(),
                                                               remoteNote.XmlContent);

                    // If the synchronized note content is in conflict
                    // and there is no saved conflict handling behavior, show the dialog
                    if (!noteSyncBitsMatch && savedBehavior == 0)
                    {
                        reponse = (Gtk.ResponseType)conflictDlg.Run();
                    }


                    if (reponse == Gtk.ResponseType.Cancel)
                    {
                        resolution = SyncTitleConflictResolution.Cancel;
                    }
                    else
                    {
                        if (noteSyncBitsMatch)
                        {
                            resolution = SyncTitleConflictResolution.OverwriteExisting;
                        }
                        else if (savedBehavior == 0)
                        {
                            resolution = conflictDlg.Resolution;
                        }
                        else
                        {
                            resolution = savedBehavior;
                        }

                        switch (resolution)
                        {
                        case SyncTitleConflictResolution.OverwriteExisting:
                            if (conflictDlg.AlwaysPerformThisAction)
                            {
                                savedBehavior = resolution;
                            }
                            // No need to delete if sync will overwrite
                            if (localConflictNote.Id != remoteNote.UUID)
                            {
                                manager.Delete(localConflictNote);
                            }
                            break;

                        case SyncTitleConflictResolution.RenameExistingAndUpdate:
                            if (conflictDlg.AlwaysPerformThisAction)
                            {
                                savedBehavior = resolution;
                            }
                            RenameNote(localConflictNote, conflictDlg.RenamedTitle, true);
                            break;

                        case SyncTitleConflictResolution.RenameExistingNoUpdate:
                            if (conflictDlg.AlwaysPerformThisAction)
                            {
                                savedBehavior = resolution;
                            }
                            RenameNote(localConflictNote, conflictDlg.RenamedTitle, false);
                            break;
                        }
                    }

                    Preferences.Set(Preferences.SYNC_CONFIGURED_CONFLICT_BEHAVIOR,
                                    (int)savedBehavior);                       // TODO: Clean up

                    conflictDlg.Hide();
                    conflictDlg.Destroy();

                    // Let the SyncManager continue
                    SyncManager.ResolveConflict(/*localConflictNote, */ resolution);
                } catch (Exception e) {
                    mainThreadException = e;
                }
            });
            if (mainThreadException != null)
            {
                throw mainThreadException;
            }
        }