public IHttpActionResult Delete(int id) { NoteRepository noterepo = new NoteRepository(); noterepo.Delete(id); return(StatusCode(HttpStatusCode.NoContent)); }
public ViewModel() { repo = new NoteRepository("ConnStrNotes"); Notes = new ObservableCollection <Note>(repo.GetNoteList()); Save = new RelayCommand(x => { repo.Save(); }); Add = new RelayCommand(x => { Note newNote = new Note(); newNote = repo.Create(newNote); repo.Save(); Notes.Add(newNote); }); Remove = new RelayCommand(x => { int id = Current.Id; Notes.Remove(Current); repo.Delete(id); repo.Save(); }, x => Notes.Count > 0); }
public void Cannot_Delete_NonExists_Note() { // Arrange var xmlDoc = new XmlDocument(); xmlDoc.LoadXml("<?xml version=\"1.0\" encoding=\"utf-16\"?><root><time>2017-08-01</time></root>"); var note = new HmmNote { Author = _author, Catalog = _catalog, Description = "testing note", Subject = "testing note is here", Content = xmlDoc.InnerXml, }; NoteRepository.Add(note); Assert.True(NoteRepository.ProcessMessage.Success); // change the note id to create a new note var orgId = note.Id; note.Id = 2; // Act var result = NoteRepository.Delete(note); // Assert Assert.False(NoteRepository.ProcessMessage.Success); Assert.False(result); // do this just to make clear up code pass note.Id = orgId; }
public void Can_Delete_Note() { // Arrange var xmlDoc = new XmlDocument(); xmlDoc.LoadXml("<?xml version=\"1.0\" encoding=\"utf-16\"?><root><time>2017-08-01</time></root>"); var note = new HmmNote { Author = _author, Catalog = _catalog, Description = "testing note", Subject = "testing note is here", Content = xmlDoc.InnerXml, }; NoteRepository.Add(note); Assert.True(NoteRepository.ProcessMessage.Success); // Act var result = NoteRepository.Delete(note); // Assert Assert.True(NoteRepository.ProcessMessage.Success); Assert.True(result); Assert.False(NoteRepository.GetEntities().Any()); }
public ActionResult Delete(long noteId) { var note = noteRepository.Load(noteId); noteRepository.Delete(note); return(RedirectToAction("Index")); }
public ActionResult Delete(int id) { Note note = nr.Find(x => x.Id == id); nr.Delete(note); return(RedirectToAction("Index")); }
public IActionResult Delete(string title) { NoteRepository noteRepository = new NoteRepository(); noteRepository.Delete(title); return(returnToIndex()); }
private void Remove() { Note noteToDelete = ChooseNote("Which note would you like to remove?"); if (noteToDelete != null) { _noteRepository.Delete(noteToDelete.Id); } }
private void Remove() { Note noteToDelete = Choose(); if (noteToDelete != null) { _noteRepository.Delete(noteToDelete.Id); } }
public async Task <ActionResult <NoteItem> > Delete(Guid id) { var note = await noteRepository.Delete(id); if (note == null) { return(NotFound()); } return(note); }
private void RemoveNotes(Notes notes, Currency currency) { var noteRepository = new NoteRepository(_sqlConnectionProvider); foreach (var noteEntity in ConvertToNoteEntities(notes, currency)) { noteRepository.Delete(noteEntity); } _totalMoney[currency].Notes.Remove(notes); }
public void DeleteNote(int id) { Note note = repository.Get(id); if (note == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } repository.Delete(id); }
public ActionResult Delete(int id) { if (id > 0) { Note note = new Note(); note = NoteRepository.GetByID(id); NoteRepository.Delete(note); } model = new NoteControllerNoteVM(); TryUpdateModel(model); return(RedirectToAction("ListNotes", "Note", new { @parentId = model.ParentContactId })); }
public IActionResult Delete(int id) { var user = GetCurrentUserProfile(); var post = _noteRepository.GetById(id); if (user.Id != post.UserId) { return(Forbid()); } _noteRepository.Delete(id); return(NoContent()); }
public void Delete_Note(object sender, RoutedEventArgs e) { Note note = (Note)Notes_Listbox.SelectedItem; _show_error(Delete_Note_Error_Message, false); if (note == null) { _show_error(Delete_Note_Error_Message, true); return; } note_repo.Delete(note.NoteId); _DataBindNotes(Notes_Listbox); }
public void TestNoteDelete() { List <Project> project_list = project_repo.All(); var project = project_list[0]; int project_id = project.ProjectId; note_repo.Add(new Note("this is a test note", project_id)); note_repo.Add(new Note("this is note 2", project_id)); int last_note_id = note_repo.GetAllByProjectId(project_id)[0].NoteId; Assert.AreEqual(2, note_repo.GetAllByProjectId(project_id).Count); note_repo.Delete(last_note_id); Assert.AreEqual(1, note_repo.GetAllByProjectId(project_id).Count); }
private void Remove() { Note noteToDelete = Choose("Which note would you like to delete?"); if (noteToDelete != null) { try { _noteRepository.Delete(noteToDelete.Id); } catch (Exception ex) { Console.WriteLine("Invalid Selection."); } } }
public void Dispose() { if (_dbContext is DbContext context) { context.Reset(); } var systems = LookupRepo.GetEntities <Subsystem>().ToList(); foreach (var sys in systems) { SubsystemRepository.Delete(sys); } var notes = LookupRepo.GetEntities <HmmNote>().ToList(); foreach (var note in notes) { NoteRepository.Delete(note); } var catalogs = LookupRepo.GetEntities <NoteCatalog>().ToList(); foreach (var catalog in catalogs) { CatalogRepository.Delete(catalog); } var renders = LookupRepo.GetEntities <NoteRender>().ToList(); foreach (var render in renders) { RenderRepository.Delete(render); } var authors = LookupRepo.GetEntities <Author>().ToList(); foreach (var author in authors) { AuthorRepository.Delete(author); } if (_dbContext is DbContext newContext) { newContext.Reset(); } GC.SuppressFinalize(this); }
public IActionResult Delete(int id) { _noteRepository.Delete(id); return(NoContent()); }
public int Delete(int id) { return(_repository.Delete(id)); }
public void DeleteNote(Note note) { _noteRepository.Delete(note); OnPropertyChanged(nameof(Notes)); }
public void Delete(Guid id) { NoteRepository.Delete(id); }
public bool Delete(int id) { return(_noteRepository.Delete(id)); }