Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

MVC Exercise

Create an application that manage a list of employees, including their name, job title, date of hire, and
date of termination using asp.net MVC 4.0
ID
MVC Ex. 1
Time
1 hours
Functionality
Creating a Database
Create a database in SQL Server or SQL Server Express with an Employee table containing
columns for name, job title, hired date, and termination date, as well as an identity
column for finding records.
1. Create a new table called Employee.
2. Create the following columns within the new table:
o Id (primary key, identity, int, not null)
o Email (varchar(50), not null)
o Name (varchar(50), not null)
o JobTitle (varchar(50), not null)
o HiredOn (date, not null)
o TerminatedOn (date, null)

Special
Instructions

USE MSSQL Express for database.

ID
MVC Ex. 1.1
Time
2 hours
Functionality
Model
Create a Model class. Not only is it the code representation for our business entity (An
Employee class contains Name, JobTitle, HiredOn, and TerminatedOn properties); it is
also responsible for how to get, save, or delete data from the database.

Special
Instructions

Validation should be performed using data annotations such as email ID should be


validated, Name should be mandatory.

ID
MVC Ex. 1.2
Time
2 hours
Functionality
Creating a Controller
Create a controller class. The controller is responsible for managing all interaction
between the end-user and the application, including identifying what data to get, save,
or delete.

Special
Instructions

Add user id and password in web.config file for authenticating the user using Authorize
action filters and if the user credential doesnt match. Application should display proper
error message.

ID
MVC Ex. 1.3
Time
4 hours
Functionality
Creating a razor view
We have our Model and we have our Controller, so it is time for our View. The View is
responsible for display onlyit should contain virtually no logic. Since our Model governs
how and our Controller governs what, think of the View as governing where, as it is
responsible for deciding where each data element gets displayed on your page.

Special
Instructions

Create custom HTML helper methods.


Use JSON format

ID
MVC Ex. 1.4
Time
4 hours
Functionality
Actions

Special
Instructions

The end user can view a list of Employees, and can create new employees, view a
particular employee details, update employee and delete an employee
Add routing constraints on ID should only contain integer values, if the URL is valid it
should get redirect to the employee detail page else proper error message should be
displayed.

You might also like