The current code lists out each Department Name and I can Browse each employee that works in the department. How can I filter by shift? I have been unsuccessful using any type of where statement.
I have two Models:
Department
public class Department
{
public int DepartmentID { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public List<Employee> Employee { get; set; }
}
and Employee
public class Employee
{
public int EmployeeID { get; set; }
public string LastName { get; set; }
[Display(Name = "First Name Middle Initial")]
public string FirstMidName { get; set; }
public DateTime HireDate { get; set; }
public string Shift { get; set; }
public int DepartmentID { get; set; }
public string FullName
{
get
{
return LastName + ", " + FirstMidName;
}
}
public virtual Department Department { get; set; }
}
Controller
public ActionResult Index()
{
var department = db.Department.OrderBy(d => d.Name).ToList();
return View(department);
}
public ActionResult Browse(string department)
{
// Retrieve Department and its Associated Employees from database
var deptModel = db.Department.Include("Employee")
.Single(g => g.Name == department);
return View(deptModel);
}