StudentPostPracticeServices.cs 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Linq.Expressions;
  5. using System.Text;
  6. using System.Transactions;
  7. using Bowin.Common.Linq;
  8. using Bowin.Common.Linq.Entity;
  9. using Bowin.Common.Utility;
  10. using EMIS.Entities;
  11. using EMIS.ViewModel;
  12. using EMIS.ViewModel.StudentManage.StudentProfile;
  13. using EMIS.DataLogic.StudentManage.StudentProfile;
  14. namespace EMIS.CommonLogic.StudentManage.StudentProfile
  15. {
  16. public class StudentPostPracticeServices : BaseServices, IStudentPostPracticeServices
  17. {
  18. public Lazy<StudentPostPracticeDAL> StudentPostPracticeDAL { get; set; }
  19. /// <summary>
  20. /// 查询对应的学生顶岗实习信息StudentPostPracticeView
  21. /// </summary>
  22. /// <param name="userID"></param>
  23. /// <param name="rowCount"></param>
  24. /// <param name="pageIndex"></param>
  25. /// <param name="pageSize"></param>
  26. /// <returns></returns>
  27. public IGridResultSet<StudentPostPracticeView> GetStudentPostPracticeViewGrid(Guid userID, int rowCount, int? pageIndex, int? pageSize)
  28. {
  29. Expression<Func<CF_StudentPostPractice, bool>> expStudentPostPractice = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  30. expStudentPostPractice = expStudentPostPractice.And(x => x.UserID == userID);
  31. var result = this.StudentPostPracticeDAL.Value.GetStudentPostPracticeViewQueryable(expStudentPostPractice).Take(rowCount).ToList();
  32. var newRowCount = rowCount - result.Count;
  33. for (var i = 0; i < newRowCount; i++)
  34. {
  35. result.Add(new StudentPostPracticeView
  36. {
  37. StudentPostPracticeID = Guid.NewGuid(),
  38. UserID = userID
  39. });
  40. }
  41. return new GridResultSet<StudentPostPracticeView> { rows = result, total = result.Count };
  42. }
  43. /// <summary>
  44. /// 编辑
  45. /// </summary>
  46. /// <param name="userID"></param>
  47. /// <param name="studentPostPracticeViewList"></param>
  48. public void StudentPostPracticeEdit(Guid userID, IList<StudentPostPracticeView> studentPostPracticeViewList)
  49. {
  50. UnitOfWork.Remove<CF_StudentPostPractice>(x => x.UserID == userID);
  51. var studentPostPracticeList = new List<CF_StudentPostPractice>();
  52. for (int i = 1; i <= studentPostPracticeViewList.Count; i++)
  53. {
  54. var studentPostPractice = studentPostPracticeViewList[i - 1];
  55. var newStudentPostPractice = new CF_StudentPostPractice
  56. {
  57. StudentPostPracticeID = Guid.NewGuid(),
  58. UserID = userID,
  59. PracticePlace = studentPostPractice.PracticePlace,
  60. StartYear = studentPostPractice.StartYear,
  61. StartMonth = studentPostPractice.StartMonth,
  62. EndYear = studentPostPractice.EndYear,
  63. EndMonth = studentPostPractice.EndMonth,
  64. PracticeMentor = studentPostPractice.PracticeMentor,
  65. PracticeContent = studentPostPractice.PracticeContent,
  66. SelfAppraise = studentPostPractice.SelfAppraise
  67. };
  68. this.SetNewStatus(newStudentPostPractice);
  69. studentPostPracticeList.Add(newStudentPostPractice);
  70. }
  71. UnitOfWork.AddRange(studentPostPracticeList);
  72. UnitOfWork.Commit();
  73. }
  74. }
  75. }