I have DB in SQL server management studio. The Employee has first_name, last_name, and department. The code in c#:
private FactoryDBEntities db = new FactoryDBEntities();
public List<Employee> GetEmployees(string fname,string lname, int department)
{
if (fname == "" && lname == "" && department == 0)
{
return db.Employee.ToList();
}
else if(fname!=""&& lname == "" && department == 0)
{
return db.Employee.Where(x => x.First_Name == fname).ToList();
}
else if(fname == "" && lname != "" && department == 0)
{
return db.Employee.Where(x => x.Last_Name == lname).ToList();
}
else
{
return db.Employee.Where(x => x.DepartmentID == department).ToList();
}
}
now I want to send from javascript to search but I don't know how I can send this.
for example from postman I send: https://localhost:44341/api/Employee?fname=John
and I received the data that I want.
Thanks.