Using Business Objects As Model in MVC
Using Business Objects As Model in MVC
Suggested Videos
return View();
}
}
insert 4 record
Step 3: Right click on the BusinessLayer class library project, and add a class file
with name = Employee.cs.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace BusinessLayer
{
public class Employee
{
public int ID { get; set; }
public string Name { get; set; }
public string Gender { get; set; }
public string City { get; set; }
public DateTime DateOfBirth { get; set; }
}
}
Step 4: Right click on the "References" folder of the "BusinessLayer" class library
project, and add a reference to "System.Configuration" assembly.
Step 5: Right click on the BusinessLayer class library project, and add a class file
with name = EmployeeBusinessLayer.cs.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
namespace BusinessLayer
{
public class EmployeeBusinessLayer
{
public IEnumerable<Employee> Employees
{
get
{
string connectionString =
ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;
employees.Add(employee);
}
}
return employees;
}
}
}
}
Step 6: Right click on the "References" folder of the "MVCDemo" project, and add a
reference to "BusinessLayer" project.
Step 8: Right click on the "Controllers" folder and add Controller with name
= "EmployeeController.cs".
public class EmployeeController : Controller
{
public ActionResult Index()
{
EmployeeBusinessLayer employeeBusinessLayer =
new EmployeeBusinessLayer();
Step 9: Right click on the Index() action method in the "EmployeeController" class
and select "Add View" from the context menu. Set
View name = Index
View engine = Razor
Select "Create a strongly-typed view" checkbox
Scaffold Template = List
Click "Add" button