5.4: Create [Post] Method
In this section, we write an [HttpPost]
method that will eventually push the data inputted in the view through our service and into the database.
Steps
Go to ElevenNote.WebMVC -> Controllers -> NoteController.cs
Add the following code under the existing
Create()
method:
QuickWatch and Data
Set a breakpoint at the spot noted in the image below:
Run the app and login.
Go to the localhost:xxxxx/Note/Create route.
Create a note
You should hit the breakpoint and it should turn yellow:
Right click on
ModelState
and click QuickWatchSlowly walkthrough the app and hover over the various points where the app is broken.
With Breakpoints and Quickwatch, You can explore the data coming from the view, and the best .NET developers use these tools often.
Persist a Note
When we save something to the database, we persist it. 1. Remove the breakpoint and rerun the app. 2. Create a note. When you hit submit, the page won't change. 3. Go to SQL Server Object Explorer. 4. Find the database and expand the tables. 5. Right click on dbo.Note
and click View Data. 6. The data is not going into the database, we'll take care of that in the next chapter by bringing in our ElevenNote.Service.
Last updated