SupervisionUserServices.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Bowin.Common.Linq.Entity;
  6. using EMIS.ViewModel.SupervisionManage;
  7. using EMIS.DataLogic.SupervisionManage;
  8. using EMIS.Entities;
  9. using EMIS.ViewModel;
  10. namespace EMIS.CommonLogic.SupervisionManage
  11. {
  12. public class SupervisionUserServices : BaseServices, ISupervisionUserServices
  13. {
  14. public SupervisionUserDAL SupervisionUserDAL { get; set; }
  15. public IGridResultSet<ProjectRecordTeacherView> GetSupervisionUserGrid(ConfiguretView conditionView, Guid? collegeID, int? pageIndex, int? pageSize)
  16. {
  17. var query = SupervisionUserDAL.GetProjectRecordTeacherView();
  18. if (collegeID.HasValue)
  19. {
  20. query = query.Where(x => x.CollegeID == collegeID);
  21. }
  22. return query.OrderBy(x => x.LoginID.Length).OrderBy(x => x.LoginID).ToGridResultSet(pageIndex, pageSize);
  23. }
  24. public ProjectRecordTeacherView GetProjectRecordTeacherView(Guid? supervisionUserID)
  25. {
  26. return SupervisionUserDAL.GetProjectRecordTeacherView().Where(x => x.SupervisionUserID == supervisionUserID).FirstOrDefault();
  27. }
  28. public void Save(ProjectRecordTeacherView projectRecordTeacherView)
  29. {
  30. var supervisionUser = new SUP_SupervisionUser();
  31. if (projectRecordTeacherView.SupervisionUserID != Guid.Empty)
  32. {
  33. supervisionUser = this.SupervisionUserDAL.SupervisionUserRepository.GetSingle(x => x.SupervisionUserID == projectRecordTeacherView.SupervisionUserID);
  34. this.SetModifyStatus(supervisionUser);
  35. }
  36. else
  37. {
  38. supervisionUser.SupervisionUserID = Guid.NewGuid();
  39. supervisionUser.UserID = projectRecordTeacherView.TeacherID;
  40. this.SetNewStatus(supervisionUser);
  41. this.UnitOfWork.Add(supervisionUser);
  42. }
  43. UnitOfWork.Commit();
  44. }
  45. public void Delete(IList<Guid?> supervisionUserIDList)
  46. {
  47. UnitOfWork.Delete<SUP_SupervisionUser>(x => supervisionUserIDList.Contains(x.SupervisionUserID));
  48. }
  49. }
  50. }