public IEnumerable <StaffDetailDTO> getStaffByBusinessUnit(string buCode) { if (String.IsNullOrEmpty(buCode)) { throw new HttpException(400, "Bad Request"); // If an ID isn't provided in the URL, a HTTP 400 exception is thrown } var staff = context.Staffs.Where(s => s.Active == true && s.BusinessUnit.businessUnitCode.Equals(buCode, StringComparison.OrdinalIgnoreCase)); // Gets all staff from the database where the active flag is true and the business unit code matches as a collection of raw data var dto = StaffDetailDTO.buildList(staff); // Passes the collection to the Staff Detail Data Transfer Object to be formatted return(dto); // Returns the fomatted data (as JSON or XML, depending on which is chosen) }