/// <summary> /// Deletes a <see cref="Note"/> object /// </summary> /// <param name="note"></param> public void Delete(Note note) { using (var repo = new NotesRepository()) { repo.Delete(note); } }
/// <summary> /// Deletes a <see cref="Note"/> object /// </summary> /// <param name="id"></param> public void Delete(int id) { using (var repo = new NotesRepository()) { repo.Delete(id); } }
public ActionResult Delete(Note model) { try { // Conversation: Check ModelState IsValid? - No, just check the Id? - No, even the Id is not needed (Id will be hidden). - Yes it is hidden, but value from html is not and can be violated/changed. // Conversation: this maybe triggers validation and also get the html form values even that I have change them here in the back-end (So, put it first Always!). //TryValidateModel(model); // Conversation: this should be cleared (for certain keys) if validating those keys is not needed. - NOPE! Just remove the props/keys from Views (hidden TOO !!!) //if (ModelState.IsValid) { } _notesRepository.Delete(model.Id); return(RedirectToAction(nameof(Index))); } catch (Exception ex) { return(View(model)); } }
public void ShouldCleanUp() { var NoteRepository = new NotesRepository(_connectionstring); foreach (var id in NotesForTests) { NoteRepository.Delete(id); } var UsersRepository = new UsersRepository(_connectionstring); foreach (var id in UsersForTests) { UsersRepository.Delete(id); } var CategoriesRepository = new CategoriesRepository(_connectionstring); foreach (var id in CategoriesForTests) { CategoriesRepository.Delete(id); } }
public void Delete(string title) { _notesRepository.Delete(title); }