There is a JSON file on My Asp.net core APi project.
I want this API to grab that file and then read all the records within that file so it is ready to display and available for requests.
For example I have list of employees in my employee.json file:
{
"EmployeeList": [
{
"EmpId": 1,
"EmpName": "Krish",
"EmpCode": 1001,
"JoiningDate": "12/07/2021",
"DeptId": 1,
"DesgId": 2
},
{
"EmpId": 2,
"EmpName": "Prish",
"EmpCode": 1002,
"JoiningDate": "17/02/2021",
"DeptId": 3,
"DesgId": 1
},
{
"EmpId": 3,
"EmpName": "Krishna",
"EmpCode": 1003,
"JoiningDate": "12/04/2020",
"DeptId": 2,
"DesgId": 2
},
{
"EmpId": 4,
"EmpName": "Ram",
"EmpCode": 1004,
"JoiningDate": "12/07/2021",
"DeptId": 1,
"DesgId": 2
},
{
"EmpId": 5,
"EmpName": "Rahul",
"EmpCode": 1005,
"JoiningDate": "10/07/2021",
"DeptId": 3,
"DesgId": 2
},
{
"EmpId": 6,
"EmpName": "Raja",
"EmpCode": 1006,
"JoiningDate": "12/01/2021",
"DeptId": 1,
"DesgId": 2
},
{
"EmpId": 7,
"EmpName": "Hiya",
"EmpCode": 1007,
"JoiningDate": "2/07/2021",
"DeptId": 3,
"DesgId": 2
},
{
"EmpId": 8,
"EmpName": "Riya",
"EmpCode": 1008,
"JoiningDate": "2/05/2021",
"DeptId": 1,
"DesgId": 3
},
{
"EmpId": 9,
"EmpName": "Sheela",
"EmpCode": 1009,
"JoiningDate": "12/10/2021",
"DeptId": 1,
"DesgId": 2
},
{
"EmpId": 10,
"EmpName": "Komal",
"EmpCode": 1010,
"JoiningDate": "12/01/2021",
"DeptId": 1,
"DesgId": 1
}
]
}
Model Class Like this:
public class Employee
{
public List<EmployeeDetail> EmployeeList { get; set; }
}
public class EmployeeDetail
{
public int EmpId { get; set; }
public string EmpName { get; set; }
public int EmpCode { get; set; }
public DateTime JoiningDate { get; set; }
public int DeptId { get; set; }
public int DesgId { get; set; }
}
Note : i dont want use database using json file and module class i need to get multiple records in Controller. Now My multiple records which i need to execute is
Find all Employees's DepartmentId where DesgId=2
Find distinct designation (i.e[{1}.{2}])
help me with some steps or code.