示例#1
0
 /// <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);
     }
 }
示例#2
0
 /// <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);
     }
 }
示例#3
0
        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));
            }
        }
示例#4
0
        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);
            }
        }
示例#5
0
 public void Delete(string title)
 {
     _notesRepository.Delete(title);
 }