CommunicateServices.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Linq.Expressions;
  6. using EMIS.ViewModel.DQPSystem;
  7. using EMIS.ViewModel;
  8. using EMIS.DataLogic.DQPSystem;
  9. using EMIS.Entities;
  10. using Bowin.Common.Linq.Entity;
  11. namespace EMIS.CommonLogic.DQPSystem
  12. {
  13. public class CommunicateServices : BaseServices, ICommunicateServices
  14. {
  15. public CommunicateDAL CommunicateDAL { get; set; }
  16. public IGridResultSet<TeacherCommunicateView> GetTeacherCommunicateViewList(ConfiguretView conditionView, Guid schoolyearID, Guid coursematerialID, Guid userID, int? pageIndex, int? pageSize)
  17. {
  18. Expression<Func<CF_Staff, bool>> staffExp = (x => x.UserID == userID);
  19. Expression<Func<DQP_SOC, bool>> socExp = (x => x.SchoolyearID == schoolyearID && x.CoursematerialID == coursematerialID);
  20. var query = this.CommunicateDAL.GetTeacherCommunicateViewQueryable(staffExp, socExp);
  21. if (!string.IsNullOrEmpty(conditionView.ConditionValue) && !string.IsNullOrEmpty(conditionView.Attribute))
  22. query = query.DynamicWhere(conditionView.Attribute, conditionView.Condition, conditionView.ConditionValue);
  23. query = query.OrderBy(x => x.ClassmajorNo)
  24. .ThenBy(x => x.LoginID);
  25. return query.ToGridResultSet(pageIndex, pageSize);
  26. }
  27. public IGridResultSet<StudentCommunicateView> GetStudentCommunicateViewList(ConfiguretView conditionView, Guid schoolyearID, Guid coursematerialID, Guid userID, int? pageIndex, int? pageSize)
  28. {
  29. Expression<Func<CF_Student, bool>> studentExp = (x => x.UserID == userID);
  30. Expression<Func<DQP_SOC, bool>> socExp = (x => x.SchoolyearID == schoolyearID && x.CoursematerialID == coursematerialID);
  31. var query = this.CommunicateDAL.GetStudentCommunicateViewQueryable(studentExp, socExp);
  32. if (!string.IsNullOrEmpty(conditionView.ConditionValue) && !string.IsNullOrEmpty(conditionView.Attribute))
  33. query = query.DynamicWhere(conditionView.Attribute, conditionView.Condition, conditionView.ConditionValue);
  34. query = query.OrderBy(x => x.RoleOrder)
  35. .ThenBy(x => x.ClassmajorNo)
  36. .ThenBy(x => x.LoginID);
  37. return query.ToGridResultSet(pageIndex, pageSize);
  38. }
  39. }
  40. }