public DataTable GetDepartmentsForSorting(DepartmentInfo _DepartmentInfo)
{
QuizEntity entity = new QuizEntity();
DataTable dt = new DataTable();
dt.Columns.Add("DeptID", typeof(double));
dt.Columns.Add("DeptName", typeof(string));
try
{
var a = entity.tblDepartments.AsQueryable();
if (_DepartmentInfo.DeptName != string.Empty)
{
a = a.Where(e => e.ClientID == _DepartmentInfo.ClientID && e.DeptName.Contains(_DepartmentInfo.DeptName)).OrderByDescending(e => e.DeptID);
}
else
{
a = a.Where(e => e.ClientID == _DepartmentInfo.ClientID).OrderBy(e => e.DeptName);
}
foreach (var dr in a)
{
DataRow row = dt.NewRow();
row.SetField<double>("DeptID", dr.DeptID);
row.SetField<string>("DeptName", dr.DeptName);
dt.Rows.Add(row);
}
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
finally
{
entity.Dispose();
}
return dt;
}
</string></double>