Let’s create a contact page for our contacts. Instead of creating a new View Model, we will be using existing ContactVM, but we will do some amendments for the purpose of validation. We are going to extend our Application from the last discussion CRUD Operations In ASP.NET Core 1.0 MVC Application - Part Three.

Add CreateContact Method in ContactBusinessLogic

  1. public Contact CreateContact(Contact contact)
  2. {
  3. contact.ContactId = ContactBusinessLogic.Contacts.Count + 1;
  4. ContactBusinessLogic.Contacts.Add(contact);
  5. return contact;
  6. }


Add CreateContact Action Methods in ContactController

Add Contact CreateContact View


Run Application in Debug Mode


Add Validation to Create Contact


Run Application in Debug Mode Again


Sample Source Code

We have placed sample code for this session in "CRUD operations in ASP.NET Core 1.0 MVC Application Part 4_Code.zip" in CodePlex repository.