so i have this code in the controller to view a list of vecation to specfic employee by his id
public JsonResult GetVacatioinList(int? Id)
{
db.Configuration.ProxyCreationEnabled = false;
List<Vacations> VList = db.Vacations.Include(c => c.VacationType).Select(x => new Vacations
{
EmployeesId = x.EmployeesId,
Id = x.Id,
VacationType = x.VacationType,
StartDate = x.StartDate,
EndDate = x.EndDate,
Duration = x.Duration
}).Where(x=> x.EmployeesId == Id).ToList();
return Json(VList, JsonRequestBehavior.AllowGet);
}
and this button will show the id for specific employee in URL
<a class='btn btn-warning' href='http://localhost:26868/Vacations/Index?id='" + EmployeesList[i].Id + "><span class='glyphicon glyphicon-list'></span></a>
now i need to compare the ID coming from URL with one in database for that user if both the same show the vacations for that employee
i tried this and it shows all the vacation when i didn't add the where condition in the LINQ statement in controller but with where there is no data shown this is my jquery code that i used
<script>
$("#LoadingStatus").html("Loading....");
$.get("/Vacations/GetVacatioinList", null, DataBind);
function DataBind(VacatioinList) {
var SetData = $("#SetVacatioinList");
for (var i = 0; i < VacatioinList.length; i++) {
if (VacatioinList[i].EmployeesId = Id) {
var dateforstart = new Date(parseInt(VacatioinList[i].StartDate.substr(6)));
var startdate = "";
startdate += dateforstart.format("mmm d, yyyy");
var dateforend = new Date(parseInt(VacatioinList[i].EndDate.substr(6)));
var enddate = "";
enddate += dateforend.format("mmm d,yyyy");
var Data = "<tr class='row_" + VacatioinList[i].Id + "'>" +
"<td>" + VacatioinList[i].Id + "</td>" +
"<td>" + VacatioinList[i].VacationType.Name + "</td>" +
"<td>" + VacatioinList[i].Duration + "</td>" +
"<td>" + startdate + "</td>" +
"<td>" + enddate + "</td>" + "</tr>";
SetData.append(Data);
$("#LoadingStatus").html("");
}
}
}
any recommendation on how to fix it or an alternative way to implement that