Finished 'Models in ASP.NET MVC'
parent
483fe19002
commit
33c8722583
|
@ -4,13 +4,17 @@ using System.Linq;
|
|||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
|
||||
using FirstMVCDemo.Models;
|
||||
|
||||
namespace FirstMVCDemo.Controllers
|
||||
{
|
||||
public class HomeController : Controller
|
||||
{
|
||||
// GET: Home
|
||||
public ActionResult Index()
|
||||
public ActionResult Index(int id)
|
||||
{
|
||||
EmployeeBusinessLayer employeeBL = new EmployeeBusinessLayer();
|
||||
Employee employee = employeeBL.GetEmployeeDetails(id);
|
||||
return View();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -97,6 +97,8 @@
|
|||
<Compile Include="Global.asax.cs">
|
||||
<DependentUpon>Global.asax</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Models\Employee.cs" />
|
||||
<Compile Include="Models\EmployeeBusinessLayer.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
@ -112,7 +114,6 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="App_Data\" />
|
||||
<Folder Include="Models\" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
namespace FirstMVCDemo.Models
|
||||
{
|
||||
public class Employee
|
||||
{
|
||||
public int EmployeeId { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Address { get; set; }
|
||||
public string City { get; set; }
|
||||
public string Gender { get; set; }
|
||||
public decimal Salary { get; set; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
namespace FirstMVCDemo.Models
|
||||
{
|
||||
public class EmployeeBusinessLayer
|
||||
{
|
||||
public Employee GetEmployeeDetails(int EmployeeId)
|
||||
{
|
||||
//Here we hardcoded the data
|
||||
//later we will discuss how to retrieve
|
||||
//the data from a database
|
||||
Employee employee = new Employee()
|
||||
{
|
||||
EmployeeId = EmployeeId,
|
||||
Name = "Pranaya",
|
||||
Gender = "Male",
|
||||
City = "Mumbai",
|
||||
Salary = 1000,
|
||||
Address = "Andheri"
|
||||
};
|
||||
return employee;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue