Description
please this should be in Visual studio I don’t want word document it should be the same as the file format that I have provided exampl file.For this homework assignment, you will build the first phase of a multi-page, data-driven Contact Manager app. The final product will allow an end-user to see a list of their contacts and be able to add new contacts, edit contact information, and delete contacts. For this first phase, you will complete the database, Home Controller, and Home Page (Index view). You will query the data using LINQ before displaying it in a view. Reference Chapter 4, as well as the Practice 4-1A exercise as needed. The topics covered in Practice 4-1A are applied in this homework assignment. You may use the starter application files provided below to begin this assignment.HW 4-1a Contact ManagerCh04ContactManager_Start.zip
Unformatted Attachment Preview
Chapter 4 How to develop a data-driven MVC web app
Homework 4-1a Build the Contact Manager app
In this assignment, you will build the first phase of a multi-page, data-driven Contact Manager app like the
one that is shown below. An end-user will be able to see a list of their contacts and be able to add new
contacts, edit contact information, and delete contacts.
Below are the screen prints for the entire application to give you an overview of what will be completed
over the course of two homework assignments.
For this assignment, you will complete the Contact Manager app’s database, Home Controller, and Home
Page (Index view). The add, edit, and delete contacts will be developed in a future assignment.
The Home page
The Add and Edit pages (both use the same view)
2
Specifications
1. Download and extract the Ch04ContactManager application starter file from D2L to the folder you are
using to keep your INFS 4950 assignments.
Code the Models and DB context
2. Create the Category.cs file in the Models folder. It includes the following properties as shown in the
diagram below (note: the varchar data type shown in the diagram is the same as the string data type in
our C# programming): Add the following properties to Category.cs.
public int CategoryId and public string Name.
3. Complete the Contact class for the data model; Contact.cs is partially completed for you. In the
Contact.cs file, you will include the foreign key CategoryId and the Category property (important: the
CategoryId is an int data type (not a string), so it will be declared as public int? CategoryId). Include
required field validation with descriptive error messages for the following properties in the Contact.cs
file: Firstname, Lastname, Phone, Email, and CategoryId. Organization and DateAdded are not required
and should be declared as follows:
public string? Organization { get; set; } //Organization is not required
public DateTime? DateAdded { get; set; } // DateAdded will be set in code; it is not required
3
4. The initial seed data is shown below. If you are using the starter files provided in D2L, the initial seed
data in the ContactContext.cs class has been provided for you. You will need to include the DbSet
properties for Contact and Category in the ContactContext.cs file.
Modify the Program.cs file for Dependency Injection
5. Configure the Program.cs file for Dependency Injection.
4
Create the Database
6. Use the Package Manager Console to add the Initial migration.
7. Update the database at the Package Manager Console. This should create the database.
8. View your dataset. To ensure the database was created correctly, display the SQL Server Object
Explorer and expand the nodes until you can see the database name you just created.
9. View the seed database by expanding the Tables node. Then, right-click on each table (Category and
Contact) and select View Data.
Modify the Home Controller
10. In the Home Controller include the context property and constructor so that other methods in this class
can easily access the context object to work with the data in your database tables.
11. Code the Index() method to query a list of all the contacts. Include the Category information for each
contact from the Category table. The Index() method should return a list of all the contacts.
Modify the Index View and Use Linq in the Home Controller to display a List of Friends
12. Modify the Home/Index view to look like the web page below (it has been started for you). In the next
assignment, we will create the code for Adding, Editing, and Deleting a contact. For this assignment, go
ahead and include a link for Add Contact, Edit, and Delete. At this time, the links will not transfer to
another page (href=”/” is used for now); they are placeholders for the functionality we will include in
the next assignment (for example, the Add a New Movie link would be coded as: Add a
New Movie).
5
The Home page listing all contacts in the database
13. Test the application thoroughly. When the app starts, it should display a list of contacts, a link to add a
contact, a link to Edit, and a link to Delete as shown in the above screen print.
14. Next, use Linq to write a query in the Index action of the Home controller that will list all your friends
(note: refer to the Category table to find the CategoryId for the Friend category).
6
The Home page listing contacts whose category is Friend
15. Feel free to be creative and experiment with some bootstrap classes, CSS, and Font Awesome if you
want to make this home page look more aesthetic. When you are satisfied with your new look for the
Contact Manager application and everything is working correctly, close the app and turn in your work.
Turn in the Contact Manager app
1. Once you are satisfied with your application, close Visual Studio, compress the Contact Manager app at
the root level, and rename the compressed folder using the following naming convention:
FirstInitial_LastName_Ch04ContactManager
For example:
M_Korzaan_Ch04ContactManager
2. Upload the renamed, compressed folder to the appropriate Dropbox in D2L.
7
Purchase answer to see full
attachment