0% found this document useful (0 votes)
5 views

09 04 2024

Uploaded by

rupams2024
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

09 04 2024

Uploaded by

rupams2024
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

public class EmployeeController : Controller

{
Employee objEmp = new Employee();

public IActionResult Index()


{
List<Employee> listEmp = new List<Employee>();
listEmp=objEmp.GetAllEmployees();
return View(listEmp);
}
}

*******************************************
public class Employee
{
[Key]
public int EmployeeId { get; set; }
public string EmployeeName { get; set; }
public string Gender { get; set; }
public int Salary { get; set; }

public List<Employee> GetAllEmployees()


{
List<Employee> employees = new List<Employee>()
{
new Employee { EmployeeId = 101, EmployeeName = "Rupa", Gender = "Female",
Salary = 4600 },
new Employee { EmployeeId = 102,
EmployeeName="Jahnavi",Gender="Male",Salary=5000},
new Employee { EmployeeId = 103,
EmployeeName="Eeswari",Gender="Female",Salary=6000},
new Employee { EmployeeId = 104,
EmployeeName="Kannaji",Gender="Male",Salary=7000}
};
return employees;
}
}
************************************************
@model IEnumerable<_09042024.Models.Employee>

@{
Layout = null;
}

<!DOCTYPE html>

<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Index</title>
</head>
<body>
<p>
<a asp-action="Create">Create New</a>
</p>
<table class="table">
<thead>
<tr>
<th>
@Html.DisplayNameFor(model => model.EmployeeId)
</th>
<th>
@Html.DisplayNameFor(model => model.EmployeeName)
</th>
<th>
@Html.DisplayNameFor(model => model.Gender)
</th>
<th>
@Html.DisplayNameFor(model => model.Salary)
</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.EmployeeId)
</td>
<td>
@Html.DisplayFor(modelItem => item.EmployeeName)
</td>
<td>
@Html.DisplayFor(modelItem => item.Gender)
</td>
<td>
@Html.DisplayFor(modelItem => item.Salary)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { /* id=item.PrimaryKey */ })
|
@Html.ActionLink("Details", "Details", new { /* id=item.PrimaryKey
*/ }) |
@Html.ActionLink("Delete", "Delete", new { /* id=item.PrimaryKey */
})
</td>
</tr>
}
<a asp-action="Act1">Click</a>
@Html.ActionLink("Go to About","Index","About");
</tbody>
</table>
</body>
</html>

You might also like