public async Task <List <EvalPeriod> > GetByUserGroupEmployee(UserGroupEmployeeReq req) { var userGroup = await UserGroupBE.GetById(new UserGroupBaseReq() { UserGroupCode = req.UserGroupCode }); if (userGroup == null) { return(null); } var employee = await EmployeeBE.GetById(new EmployeeBaseReq { EmployeeId = req.EmpoyeeId }); if (employee == null) { return(null); } var result = new List <EvalPeriod>(); if (userGroup.EduLevelCode == EnumEduLevelCode.School) { if (userGroup.UserGroupCode == EnumUserGroup.SchoolTeacher) { result = (await GetAsync(p => p.SchoolId == employee.SchoolId && p.EvalTypeCode == EnumEvalType.Teacher))?.ToList(); } else if (userGroup.UserGroupCode == EnumUserGroup.SubSchoolPrimary || userGroup.UserGroupCode == EnumUserGroup.SchoolPrimary) { result = (await GetAsync(p => p.SchoolId == employee.SchoolId && p.EvalTypeCode == EnumEvalType.Primary))?.ToList(); } else if (userGroup.UserGroupCode == EnumUserGroup.Officer) { result = (await GetAsync(p => p.SchoolId == employee.SchoolId && p.EvalTypeCode == EnumEvalType.Primary))?.ToList(); } else { result = (await GetAsync(p => p.SchoolId == employee.SchoolId))?.ToList(); } } else { result = null; } if (result != null) { foreach (var p in result) { p.EvalMasters = null; } } return(result); }
public async Task <List <School> > GetByUserGroupEmployee(UserGroupEmployeeReq req) { var userGroup = await UserGroupBE.GetById(new UserGroupBaseReq() { UserGroupCode = req.UserGroupCode }); if (userGroup == null) { return(null); } var employee = await EmployeeBE.GetById(new EmployeeBaseReq { EmployeeId = req.EmpoyeeId }); if (employee == null) { return(null); } var result = new List <School>(); if (userGroup.EduLevelCode == EnumEduLevelCode.Ministry || userGroup.EduLevelCode == EnumEduLevelCode.TAdmin) { result = (await GetAllAsync())?.ToList(); } else if (userGroup.EduLevelCode == EnumEduLevelCode.Province) { result = (await GetAsync(p => p.EduProvinceId == employee.EduProvinceId))?.ToList(); } else if (userGroup.EduLevelCode == EnumEduLevelCode.Department) { result = (await GetAsync(p => p.EduDepartmentId == employee.EduDepartmentId))?.ToList(); } else if (userGroup.EduLevelCode == EnumEduLevelCode.School) { result = (await GetAsync(p => p.SchoolId == employee.SchoolId))?.ToList(); } return(result); }