10.0: NoteDelete
Last updated
Last updated
In this section, we'll write the code to get rid of a note.
Open NoteController.cs
Copy the Details(int id)
method
Paste it underneath the Edit(int id, NoteEdit model)
method
Change the name to Delete
Right click on Delete(int id)
and add a view:
Back in NoteController.cs
, create an ActionResult
to remove the note from the database
This will need a different name due to overloading issues
Add some validation to the code:
Ignore the error for now, it will go away once we add the code below in the NoteService
Open NoteService.cs
Create a Delete
method under the UpdateNote
method:
Run the app and make sure you can delete a note
You should get a message that your note was deleted
Open up your dbo.Note
to confirm that the specified note was deleted.
Before
After
Next, we'll change the date/time format