diff --git a/VOL.Business/Services/HomeWork/S_HomeWorkService.cs b/VOL.Business/Services/HomeWork/S_HomeWorkService.cs index 56eeff2..75e3773 100644 --- a/VOL.Business/Services/HomeWork/S_HomeWorkService.cs +++ b/VOL.Business/Services/HomeWork/S_HomeWorkService.cs @@ -72,7 +72,13 @@ namespace VOL.Business.Services.Norm WorkId = s.Id, TeacherId = s.TeacherId, StudentScope = s.StudentScope, - WorkStatus = s.EndTime < currentTime ? HomeWorkStatus.Ended : (s.StartTime > currentTime ? HomeWorkStatus.NotStarted : HomeWorkStatus.Afoot), + WorkStatus = + currentTime < s.StartTime + ? HomeWorkStatus.NotStarted + : currentTime > s.EndTime + ? HomeWorkStatus.Ended + : HomeWorkStatus.Afoot, + TeacherName = s.TeacherName, WorkName = s.WorkName, WorkText = s.WorkText, @@ -92,19 +98,35 @@ namespace VOL.Business.Services.Norm query = query.Where(x => x.WorkType == paramDto.WorkType); } - if (paramDto.StudentScope > 0) - { - query = query.Where(x => x.StudentScope == paramDto.StudentScope); - } + //if (paramDto.StudentScope > 0) + //{ + // query = query.Where(x => x.StudentScope == paramDto.StudentScope); + //} if (paramDto.WorkStatus > 0) { - query = query.Where(x => x.WorkStatus == paramDto.WorkStatus); + switch ((HomeWorkStatus)paramDto.WorkStatus) + { + case HomeWorkStatus.Ended: + query = query.Where(s => s.EndTime < currentTime); + break; + + case HomeWorkStatus.NotStarted: + query = query.Where(s => s.StartTime > currentTime); + break; + + case HomeWorkStatus.Afoot: + query = query.Where(s => + s.StartTime <= currentTime && + s.EndTime >= currentTime); + break; + } } + if (!string.IsNullOrWhiteSpace(paramDto.TeacherName)) { - query = query.Where(x => x.TeacherName == paramDto.TeacherName); + query = query.Where(x => x.TeacherName.Contains(paramDto.TeacherName)); } if (paramDto.StartTime.HasValue)