SOCDetailScoreDAL.cs 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.DataLogic.Repositories;
  6. using EMIS.ViewModel.DQPSystem;
  7. using EMIS.Entities;
  8. using System.Linq.Expressions;
  9. using EMIS.ViewModel;
  10. using EMIS.ViewModel.Students;
  11. using EMIS.DataLogic.Common.Students;
  12. namespace EMIS.DataLogic.DQPSystem
  13. {
  14. public class SOCDetailScoreDAL
  15. {
  16. public SOCDetailStudentScoreRepository SOCDetailStudentScoreRepository { get; set; }
  17. public SOCDetailStudentAttachmentRepository SOCDetailStudentAttachmentRepository { get; set; }
  18. public SOCDetailGroupRepository SOCDetailGroupRepository { get; set; }
  19. public SOCDetailStudentRepository SOCDetailStudentRepository { get; set; }
  20. public SOCDetailRepository SOCDetailRepository { get; set; }
  21. public SOCRepository SOCRepository { get; set; }
  22. public SchoolyearRepository SchoolyearRepository { get; set; }
  23. public CoursematerialRepository CoursematerialRepository { get; set; }
  24. public FacultymajorRepository FacultymajorRepository { get; set; }
  25. public GrademajorRepository GrademajorRepository { get; set; }
  26. public ClassmajorRepository ClassmajorRepository { get; set; }
  27. public CollegeRepository CollegeRepository { get; set; }
  28. public StudentRepository StudentRepository { get; set; }
  29. public UserRepository UserRepository { get; set; }
  30. public DepartmentRepository DepartmentRepository { get; set; }
  31. public EducationMissionRepository educationMissionRepository { get; set; }
  32. public Lazy<StudentsDAL> StudentsDAL { get; set; }
  33. public IQueryable<SOCDetailStudentScoreView> GetSOCDetailStudentScoreView(Guid userID, Expression<Func<DQP_SOC, bool>> socExp,
  34. Expression<Func<CF_Facultymajor, bool>> facultyExp,
  35. Expression<Func<CF_Grademajor, bool>> gradeExp,
  36. Expression<Func<CF_Classmajor, bool>> classExp)
  37. {
  38. var sql = (from soc in SOCRepository.GetList(socExp).Where(x => x.DQP_SOCStaff.Any(w => w.UserID == userID))
  39. join edu in educationMissionRepository.Entities
  40. on soc.EducationMissionID equals edu.EducationMissionID
  41. into gedu
  42. from edu in gedu.DefaultIfEmpty()
  43. join schoolyear in SchoolyearRepository.Entities on soc.SchoolyearID equals schoolyear.SchoolyearID
  44. join course in CoursematerialRepository.Entities on soc.CoursematerialID equals course.CoursematerialID
  45. join detail in SOCDetailRepository.Entities.Where(x => x.IsGroup != true && x.CreateUserID == userID) on soc.SOCID equals detail.SOCID
  46. from student in soc.CF_Student
  47. join user in UserRepository.Entities on student.UserID equals user.UserID
  48. from socTeacher in student.DQP_SOCStaff.Where(x => x.SOCID == soc.SOCID && x.UserID == userID && x.TeachingMethod == (int)EM_TeachingMethod.Lecturer)
  49. //join classmajor in ClassmajorRepository.Entities.Where(classExp) on student.ClassmajorID equals classmajor.ClassmajorID
  50. //join grade in GrademajorRepository.Entities.Where(gradeExp) on classmajor.GrademajorID equals grade.GrademajorID
  51. //join faculty in FacultymajorRepository.Entities.Where(facultyExp) on grade.FacultymajorID equals faculty.FacultymajorID
  52. from studentdetail in SOCDetailStudentRepository.Entities.Where(x => x.SOCDetailID == detail.SOCDetailID
  53. && x.UserID == student.UserID).DefaultIfEmpty()
  54. from score in SOCDetailStudentScoreRepository.Entities
  55. .Where(x => x.SOCDetailID == detail.SOCDetailID && x.UserID == student.UserID).DefaultIfEmpty()
  56. select new SOCDetailStudentScoreView
  57. {
  58. SOCID = soc.SOCID,
  59. EducationMissionID = soc.EducationMissionID,
  60. EducationMissionName = edu.ClassName,
  61. SchoolyearID = soc.SchoolyearID,
  62. SchoolyearCode = schoolyear.Code,
  63. CoursematerialID = course.CoursematerialID,
  64. CourseCode = course.CourseCode,
  65. CourseName = course.CourseName,
  66. ClassmajorID = student.ClassmajorID,
  67. //ClassmajorNo = classmajor.No,
  68. //ClassmajorName = classmajor.Name,
  69. UserID = student.UserID,
  70. LoginID = user.LoginID,
  71. Name = user.Name,
  72. SOCDetailStudentID = studentdetail.SOCDetailStudentID,
  73. SOCDetailID = detail.SOCDetailID,
  74. SOCDetailName = detail.Name,
  75. SOCDetailCredit = detail.Credit,
  76. Weight = detail.Weight,
  77. Score = score.Score,
  78. Credit = score.Credit,
  79. Remark = studentdetail.Remark,
  80. RecordStatus = studentdetail.RecordStatus ?? (int)DQP_SOCDetailSubmitStatus.NotSubmit
  81. });
  82. return sql;
  83. }
  84. public IQueryable<SOCDetailStudentScoreView> GetSOCDetailView(Guid userID, Expression<Func<DQP_SOC, bool>> socExp,
  85. Expression<Func<CF_Facultymajor, bool>> facultyExp,
  86. Expression<Func<CF_Grademajor, bool>> gradeExp,
  87. Expression<Func<CF_Classmajor, bool>> classExp)
  88. {
  89. var sql = (from soc in SOCRepository.GetList(socExp).Where(x => x.DQP_SOCStaff.Any(w => w.UserID == userID))
  90. join edu in educationMissionRepository.Entities
  91. on soc.EducationMissionID equals edu.EducationMissionID
  92. into gedu
  93. from edu in gedu.DefaultIfEmpty()
  94. join schoolyear in SchoolyearRepository.Entities on soc.SchoolyearID equals schoolyear.SchoolyearID
  95. join course in CoursematerialRepository.Entities on soc.CoursematerialID equals course.CoursematerialID
  96. join detail in SOCDetailRepository.Entities.Where(x => x.IsGroup != true) on soc.SOCID equals detail.SOCID
  97. from student in soc.CF_Student
  98. join user in UserRepository.Entities on student.UserID equals user.UserID
  99. join classmajor in ClassmajorRepository.Entities on student.ClassmajorID equals classmajor.ClassmajorID
  100. join grade in GrademajorRepository.Entities on classmajor.GrademajorID equals grade.GrademajorID
  101. from studentdetail in SOCDetailStudentRepository.Entities.Where(x => x.SOCDetailID == detail.SOCDetailID
  102. && x.UserID == student.UserID).DefaultIfEmpty()
  103. from score in SOCDetailStudentScoreRepository.Entities
  104. .Where(x => x.SOCDetailID == detail.SOCDetailID && x.UserID == student.UserID).DefaultIfEmpty()
  105. from attachment in studentdetail.DQP_SOCDetailStudentAttachment
  106. select new SOCDetailStudentScoreView
  107. {
  108. SOCID = soc.SOCID,
  109. EducationMissionID = soc.EducationMissionID,
  110. EducationMissionName = edu.ClassName,
  111. SchoolyearID = soc.SchoolyearID,
  112. SchoolyearCode = schoolyear.Code,
  113. CoursematerialID = course.CoursematerialID,
  114. CourseCode = course.CourseCode,
  115. CourseName = course.CourseName,
  116. ClassmajorID = student.ClassmajorID,
  117. YearID = grade.GradeID,
  118. UserID = student.UserID,
  119. LoginID = user.LoginID,
  120. Name = user.Name,
  121. SOCDetailStudentID = studentdetail.SOCDetailStudentID,
  122. SOCDetailID = detail.SOCDetailID,
  123. SOCDetailName = detail.Name,
  124. SOCDetailCredit = detail.Credit,
  125. Weight = detail.Weight,
  126. Score = score.Score,
  127. Credit = score.Credit,
  128. Remark = studentdetail.Remark,
  129. RecordStatus = studentdetail.RecordStatus ?? (int)DQP_SOCDetailSubmitStatus.NotSubmit,
  130. SOCDetailUrl=attachment.Url,
  131. FileName = attachment.Name
  132. });
  133. return sql;
  134. }
  135. public IQueryable<SOCDetailStudentScoreView> GetSOCDetailView(Expression<Func<DQP_SOCDetail, bool>> socExp,Guid? userID)
  136. {
  137. var sql = (from soc in SOCRepository.GetList(x => true)
  138. join edu in educationMissionRepository.Entities
  139. on soc.EducationMissionID equals edu.EducationMissionID
  140. into gedu
  141. from edu in gedu.DefaultIfEmpty()
  142. join schoolyear in SchoolyearRepository.Entities on soc.SchoolyearID equals schoolyear.SchoolyearID
  143. join course in CoursematerialRepository.Entities on soc.CoursematerialID equals course.CoursematerialID
  144. join detail in SOCDetailRepository.GetList(socExp).Where(x => x.IsGroup != true) on soc.SOCID equals detail.SOCID
  145. from student in soc.CF_Student
  146. join user in UserRepository.Entities.Where(x => x.UserID == userID) on student.UserID equals user.UserID
  147. join classmajor in ClassmajorRepository.Entities on student.ClassmajorID equals classmajor.ClassmajorID
  148. join grade in GrademajorRepository.Entities on classmajor.GrademajorID equals grade.GrademajorID
  149. from studentdetail in SOCDetailStudentRepository.Entities.Where(x => x.SOCDetailID == detail.SOCDetailID
  150. && x.UserID == student.UserID).DefaultIfEmpty()
  151. from score in SOCDetailStudentScoreRepository.Entities
  152. .Where(x => x.SOCDetailID == detail.SOCDetailID && x.UserID == student.UserID).DefaultIfEmpty()
  153. select new SOCDetailStudentScoreView
  154. {
  155. SOCID = soc.SOCID,
  156. EducationMissionID = soc.EducationMissionID,
  157. EducationMissionName = edu.ClassName,
  158. SchoolyearID = soc.SchoolyearID,
  159. SchoolyearCode = schoolyear.Code,
  160. CoursematerialID = course.CoursematerialID,
  161. CourseCode = course.CourseCode,
  162. CourseName = course.CourseName,
  163. ClassmajorID = student.ClassmajorID,
  164. YearID = grade.GradeID,
  165. UserID = student.UserID,
  166. LoginID = user.LoginID,
  167. Name = user.Name,
  168. SOCDetailStudentID = studentdetail.SOCDetailStudentID,
  169. SOCDetailID = detail.SOCDetailID,
  170. SOCDetailName = detail.Name,
  171. SOCDetailCredit = detail.Credit,
  172. Weight = detail.Weight,
  173. Score = score.Score,
  174. Credit = score.Credit,
  175. Remark = studentdetail.Remark,
  176. RecordStatus = studentdetail.RecordStatus ?? (int)DQP_SOCDetailSubmitStatus.NotSubmit
  177. });
  178. return sql;
  179. }
  180. public IQueryable<SOCDetailRawScoreView> GetSOCDetailRawScoreView(Expression<Func<DQP_SOC, bool>> socExp,
  181. Expression<Func<DQP_SOCDetail, bool>> detailExp,
  182. Expression<Func<CF_Facultymajor, bool>> facultyExp,
  183. Expression<Func<CF_Grademajor, bool>> gradeExp,
  184. Expression<Func<CF_Classmajor, bool>> classExp,
  185. Expression<Func<Sys_User, bool>> userExp)
  186. {
  187. var sql = (from soc in SOCRepository.GetList(socExp)
  188. join department in DepartmentRepository.Entities on soc.DepartmentID equals department.DepartmentID
  189. into fdep
  190. from department in fdep.DefaultIfEmpty()
  191. join schoolyear in SchoolyearRepository.Entities on soc.SchoolyearID equals schoolyear.SchoolyearID
  192. join course in CoursematerialRepository.Entities on soc.CoursematerialID equals course.CoursematerialID
  193. join detail in SOCDetailRepository.GetList(detailExp) on soc.SOCID equals detail.SOCID
  194. from student in soc.CF_Student
  195. join user in UserRepository.Entities.Where(userExp) on student.UserID equals user.UserID
  196. join classmajor in ClassmajorRepository.Entities.Where(classExp) on student.ClassmajorID equals classmajor.ClassmajorID
  197. join grade in GrademajorRepository.Entities.Where(gradeExp) on classmajor.GrademajorID equals grade.GrademajorID
  198. join faculty in FacultymajorRepository.Entities.Where(facultyExp) on grade.FacultymajorID equals faculty.FacultymajorID
  199. from score in SOCDetailStudentScoreRepository.Entities
  200. .Where(x => x.SOCDetailID == detail.SOCDetailID && x.UserID == student.UserID).DefaultIfEmpty()
  201. from creator in UserRepository.Entities.Where(x => x.UserID == score.CreateUserID).DefaultIfEmpty()
  202. select new SOCDetailRawScoreView
  203. {
  204. SOCID = soc.SOCID,
  205. SchoolyearID = soc.SchoolyearID,
  206. SchoolyearCode = schoolyear.Code,
  207. CoursematerialID = course.CoursematerialID,
  208. CourseCode = course.CourseCode,
  209. CourseName = course.CourseName,
  210. DepartmentID = soc.DepartmentID,
  211. CollegeID = department.CollegeID,
  212. TotalCredit = soc.Credit,
  213. ClassmajorID = student.ClassmajorID,
  214. ClassmajorNo = classmajor.No,
  215. ClassmajorName = classmajor.Name,
  216. Gradeyear = grade.GradeID,
  217. StandardID = faculty.StandardID,
  218. UserID = student.UserID,
  219. LoginID = user.LoginID,
  220. Name = user.Name,
  221. SOCDetailID = detail.SOCDetailID,
  222. SOCDetailName = detail.Name,
  223. SOCDetailCredit = detail.Credit,
  224. Weight = detail.Weight,
  225. Score = score.Score,
  226. Credit = score.Credit,
  227. CreateTime = score.CreateTime,
  228. CreateUserID = score.CreateUserID,
  229. CreateUserName = creator.Name
  230. });
  231. return sql;
  232. }
  233. public IOrderedQueryable<FileUploadView> GetSOCDetailStudentAttachmentView(Expression<Func<DQP_SOCDetailStudent, bool>> exp)
  234. {
  235. var tableName = typeof(DQP_SOCDetailStudentAttachment).Name;
  236. var sql = (from student in SOCDetailStudentRepository.GetList(exp)
  237. from attachment in student.DQP_SOCDetailStudentAttachment
  238. orderby attachment.CreateTime descending
  239. select new FileUploadView
  240. {
  241. FileID = attachment.SOCDetailStudentAttachmentID,
  242. FileName = attachment.Name,
  243. FileUrl = attachment.Url,
  244. FormID = attachment.SOCDetailStudentID,
  245. TableName = tableName
  246. });
  247. return (IOrderedQueryable<FileUploadView>)sql;
  248. }
  249. public IOrderedQueryable<FileUploadView> GetSOCDetailGroupAttachmentView(Expression<Func<DQP_SOCDetailGroup, bool>> exp)
  250. {
  251. var tableName = typeof(DQP_SOCDetailStudentAttachment).Name;
  252. var sql = (from @group in SOCDetailGroupRepository.GetList(exp)
  253. from attachment in @group.DQP_SOCDetailStudentAttachment
  254. orderby attachment.CreateTime descending
  255. select new FileUploadView
  256. {
  257. FileID = attachment.SOCDetailStudentAttachmentID,
  258. FileName = attachment.Name,
  259. FileUrl = attachment.Url,
  260. FormID = attachment.SOCDetailGroupID,
  261. TableName = tableName
  262. });
  263. return (IOrderedQueryable<FileUploadView>)sql;
  264. }
  265. public IQueryable<BaseStudentView> GetSOCDetailGroupStudentView(Expression<Func<DQP_SOCDetailGroup, bool>> exp)
  266. {
  267. var baseStudentQuerable = StudentsDAL.Value.GetBaseStudentViewQueryable(x => true);
  268. var sql = (from @group in SOCDetailGroupRepository.GetList(exp)
  269. from student in @group.CF_Student
  270. from view in baseStudentQuerable.Where(x => x.UserID == student.UserID)
  271. select view);
  272. return sql;
  273. }
  274. public IQueryable<SOCDetailGroupScoreView> GetSOCDetailGroupScoreView(Guid userID, Expression<Func<DQP_SOC, bool>> socExp,
  275. Expression<Func<CF_Facultymajor, bool>> facultyExp,
  276. Expression<Func<CF_Grademajor, bool>> gradeExp,
  277. Expression<Func<CF_Classmajor, bool>> classExp)
  278. {
  279. var sql = (from soc in SOCRepository.GetList(socExp).Where(x => x.DQP_SOCStaff.Any(w => w.UserID == userID))
  280. join edu in educationMissionRepository.Entities
  281. on soc.EducationMissionID equals edu.EducationMissionID
  282. into gedu
  283. from edu in gedu.DefaultIfEmpty()
  284. join schoolyear in SchoolyearRepository.Entities on soc.SchoolyearID equals schoolyear.SchoolyearID
  285. join course in CoursematerialRepository.Entities on soc.CoursematerialID equals course.CoursematerialID
  286. join detail in SOCDetailRepository.Entities.Where(x => x.IsGroup == true && x.CreateUserID == userID) on soc.SOCID equals detail.SOCID
  287. //from classmajor in soc.CF_Classmajor
  288. //join grade in GrademajorRepository.Entities.Where(gradeExp) on classmajor.GrademajorID equals grade.GrademajorID
  289. //join faculty in FacultymajorRepository.Entities.Where(facultyExp) on grade.FacultymajorID equals faculty.FacultymajorID
  290. from @group in SOCDetailGroupRepository.Entities
  291. .Where(x => x.SOCDetailID == detail.SOCDetailID && x.CF_Student.Any(w => w.DQP_SOCStaff.Any(v => v.SOCID == soc.SOCID && v.UserID == userID && v.TeachingMethod == (int)EM_TeachingMethod.Lecturer)))
  292. select new SOCDetailGroupScoreView
  293. {
  294. SOCID = soc.SOCID,
  295. EducationMissionID = soc.EducationMissionID,
  296. EducationMissionName = edu.ClassName,
  297. SchoolyearID = soc.SchoolyearID,
  298. SchoolyearCode = schoolyear.Code,
  299. CoursematerialID = course.CoursematerialID,
  300. CourseCode = course.CourseCode,
  301. CourseName = course.CourseName,
  302. //ClassmajorID = classmajor.ClassmajorID,
  303. //ClassmajorNo = classmajor.No,
  304. //ClassmajorName = classmajor.Name,
  305. SOCDetailGroupID = @group.SOCDetailGroupID,
  306. No = @group.No,
  307. SOCDetailID = detail.SOCDetailID,
  308. SOCDetailName = detail.Name,
  309. SOCDetailCredit = detail.Credit,
  310. Weight = detail.Weight,
  311. Score = @group.Score,
  312. Remark = @group.Remark,
  313. RecordStatus = @group.RecordStatus
  314. });
  315. return sql;
  316. }
  317. public IQueryable<SOCDetailGroupScoreView> GetSOCDetailGroup(Guid userID, Expression<Func<DQP_SOC, bool>> socExp,
  318. Expression<Func<CF_Facultymajor, bool>> facultyExp,
  319. Expression<Func<CF_Grademajor, bool>> gradeExp,
  320. Expression<Func<CF_Classmajor, bool>> classExp)
  321. {
  322. var sql = (from soc in SOCRepository.GetList(socExp).Where(x => x.DQP_SOCStaff.Any(w => w.UserID == userID))
  323. join edu in educationMissionRepository.Entities
  324. on soc.EducationMissionID equals edu.EducationMissionID
  325. into gedu
  326. from edu in gedu.DefaultIfEmpty()
  327. join schoolyear in SchoolyearRepository.Entities on soc.SchoolyearID equals schoolyear.SchoolyearID
  328. join course in CoursematerialRepository.Entities on soc.CoursematerialID equals course.CoursematerialID
  329. join detail in SOCDetailRepository.Entities.Where(x => x.IsGroup == true && x.CreateUserID == userID) on soc.SOCID equals detail.SOCID
  330. from @group in SOCDetailGroupRepository.Entities
  331. .Where(x => x.SOCDetailID == detail.SOCDetailID && x.CF_Student.Any(w => w.DQP_SOCStaff.Any(v => v.SOCID == soc.SOCID && v.UserID == userID && v.TeachingMethod == (int)EM_TeachingMethod.Lecturer)))
  332. from student in @group.CF_Student
  333. from attachment in @group.DQP_SOCDetailStudentAttachment
  334. select new SOCDetailGroupScoreView
  335. {
  336. SOCID = soc.SOCID,
  337. EducationMissionID = soc.EducationMissionID,
  338. EducationMissionName = edu.ClassName,
  339. SchoolyearID = soc.SchoolyearID,
  340. SchoolyearCode = schoolyear.Code,
  341. CoursematerialID = course.CoursematerialID,
  342. CourseCode = course.CourseCode,
  343. CourseName = course.CourseName,
  344. SOCDetailGroupID = @group.SOCDetailGroupID,
  345. No = @group.No,
  346. SOCDetailID = detail.SOCDetailID,
  347. SOCDetailName = detail.Name,
  348. SOCDetailCredit = detail.Credit,
  349. Weight = detail.Weight,
  350. Score = @group.Score,
  351. Remark = @group.Remark,
  352. RecordStatus = @group.RecordStatus,
  353. SOCDetailUrl=attachment.Url,
  354. FileName=attachment.Name
  355. });
  356. return sql;
  357. }
  358. public IList<SOCStudentScoreItemView> GetSOCStudentScoreItemViewQueryable(Guid userID)
  359. {
  360. var query = from score in SOCDetailStudentScoreRepository.Entities
  361. from detail in SOCDetailRepository.Entities.Where(x => x.SOCDetailID == score.SOCDetailID)
  362. from soc in SOCRepository.Entities.Where(x => x.SOCID == detail.SOCID)
  363. from schoolyear in SchoolyearRepository.Entities.Where(x => x.SchoolyearID == soc.SchoolyearID)
  364. from course in CoursematerialRepository.Entities.Where(x => x.CoursematerialID == soc.CoursematerialID)
  365. from student in StudentRepository.Entities.Where(x => score.UserID == x.UserID)
  366. from classmajor in ClassmajorRepository.Entities.Where(x => x.ClassmajorID == student.ClassmajorID)
  367. from grade in GrademajorRepository.Entities.Where(x => x.GrademajorID == classmajor.GrademajorID)
  368. from gradeSchoolyear in SchoolyearRepository.Entities.Where(x => x.Years == grade.GradeID && x.SchoolcodeID == grade.SemesterID)
  369. where (score.UserID == userID)
  370. group new { Score = score, Detail = detail } by new
  371. {
  372. UserID = score.UserID,
  373. CourseName = course.CourseName,
  374. Credit = soc.Credit,
  375. CoursematerialID = course.CoursematerialID,
  376. SchoolyearNumID = (schoolyear.Value - gradeSchoolyear.Value - (schoolyear.SchoolcodeID == gradeSchoolyear.SchoolcodeID ? 0 : 1)) / 2 + 1,
  377. StarttermID = schoolyear.Value - gradeSchoolyear.Value + 1
  378. } into g
  379. orderby new { StarttermID = g.Key.StarttermID, g.Key.CourseName }
  380. select new SOCStudentScoreItemView()
  381. {
  382. UserID = g.Key.UserID,
  383. CourseName = g.Key.CourseName,
  384. TotalScore = g.Sum(x => (x.Score.Score * x.Detail.Weight) / 100),
  385. ScoreCredit = g.Sum(x => (x.Score.Score * x.Detail.Weight) / 100) > 60 ? g.Key.Credit : 0,
  386. CoursematerialID = g.Key.CoursematerialID,
  387. SchoolyearNumID = g.Key.SchoolyearNumID,
  388. StarttermID = g.Key.StarttermID
  389. };
  390. return query.ToList();
  391. }
  392. public SOCStudentScoreTotalView GetSOCStudentScoreItemView(Guid userID)
  393. {
  394. var query = from student in StudentRepository.Entities.Where(x => x.UserID == userID)
  395. from classmajor in ClassmajorRepository.Entities.Where(x => x.ClassmajorID == student.ClassmajorID)
  396. from grade in GrademajorRepository.Entities.Where(x => x.GrademajorID == classmajor.GrademajorID)
  397. from faculty in FacultymajorRepository.Entities.Where(x => x.FacultymajorID == grade.FacultymajorID)
  398. from college in CollegeRepository.Entities.Where(x => x.CollegeID == faculty.CollegeID)
  399. select new SOCStudentScoreTotalView
  400. {
  401. UserID = student.UserID,
  402. UserName = student.Sys_User.Name,
  403. CollegeName = college.Name,
  404. ClassName = classmajor.Name,
  405. PlanningGraduateDate = student.PlanningGraduateDate
  406. };
  407. return query.FirstOrDefault();
  408. }
  409. public IQueryable<DQP_SOCDetailStudentScore> GetStudentScoreBySOCDetailStudent(Expression<Func<DQP_SOCDetailStudent, bool>> exp)
  410. {
  411. var query = from student in SOCDetailStudentRepository.GetList(exp)
  412. from score in SOCDetailStudentScoreRepository.Entities.Where(x => student.SOCDetailID == x.SOCDetailID && student.UserID == x.UserID)
  413. select score;
  414. return query;
  415. }
  416. public IQueryable<DQP_SOCDetailStudentScore> GetStudentScoreBySOCDetailGroup(Expression<Func<DQP_SOCDetailGroup, bool>> exp)
  417. {
  418. var query = from @group in SOCDetailGroupRepository.GetList(exp)
  419. from student in @group.CF_Student
  420. from score in SOCDetailStudentScoreRepository.Entities.Where(x => @group.SOCDetailID == x.SOCDetailID && student.UserID == x.UserID)
  421. select score;
  422. return query;
  423. }
  424. }
  425. }