ASP – Data Entry MVC Application with Database – Video

After the first video for MVC here, I have decided to make a next part, in which I save the entries to a database and display them:







Sounds like a tiny update. However, it is not that tiny. 🙂  I have added 2 more projects to the solution:

  • PartyDB
  • PartyLibrary

The idea of those was to facilitate the database connection and display. The PartyDB consists of one sql file, however, it is added to the server through VisualStudio and its publishing feature, thus it is quite valuable:

The PartyLibrary is a bit more tricky. It has 3 classes:

  • DataAccess.cs – pretty straight forward, returning saving the data with Dapper and providing access to the connection string

  • GuestModel.cs – used for mapping the guestModel to the database. It is a bit different from the GuestResponse.cs class, because the GuestResponse.cs takes the response data from the web site and the GuestModel takes this data and writes it to the Database. E.g., the GuestModel.cs has public int Id { get; set; } and public string AnimalName { get; set; } , which are generated from the code and not from the data entry:

  • GuestProcessor.cs – it takes the data from the data entry and adds it to the database. Posses one function only:

To the controllers class, a new controller is added. It takes the data from the database and displays it in a view:

The view for the database, using the guestList looks like this:

List of party people:

@foreach (PartyLibrary2.GuestModel g in Model)


NickName FancyMail FavouriteAnimal
@g.NickName @g.FancyMail @g.AnimalName

Pretty much this is how it looks on a video:

The code is available in GitHub.


Tagged with: , , , , ,