StudentExperienceServices.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.DataLogic.Common.Students;
  6. using Bowin.Common.Linq.Entity;
  7. using EMIS.ViewModel.Students;
  8. using System.Linq.Expressions;
  9. using EMIS.Entities;
  10. using EMIS.ViewModel;
  11. namespace EMIS.CommonLogic.Students
  12. {
  13. public class StudentExperienceServices : BaseServices, IStudentExperienceServices
  14. {
  15. public StudentExperienceDAL StudentExperienceDAL { get; set; }
  16. public IGridResultSet<StudentExperienceView> GetTopStudentExperienceGridView(Guid userID, int rowCount, int? pageIndex, int? pageSize)
  17. {
  18. Expression<Func<CF_StudentExperience, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE
  19. && x.UserID == userID);
  20. var result = this.StudentExperienceDAL.GetStudentExperienceViewQueryable(exp).Take(rowCount).ToList();
  21. var newRowCount = rowCount - result.Count;
  22. for (var i = 0; i < newRowCount; i++)
  23. {
  24. result.Add(new StudentExperienceView
  25. {
  26. StudentExperienceID = Guid.NewGuid(),
  27. UserID = userID
  28. });
  29. }
  30. return new GridResultSet<StudentExperienceView> { rows = result, total = result.Count };
  31. }
  32. public void Save(Guid userID, IList<StudentExperienceView> studentExperienceViewList)
  33. {
  34. UnitOfWork.Remove<CF_StudentExperience>(x => x.UserID == userID);
  35. var studentExperienceList = (from experience in studentExperienceViewList
  36. select new CF_StudentExperience
  37. {
  38. StudentExperienceID = Guid.NewGuid(),
  39. UserID = userID,
  40. StartYear = experience.StartYear,
  41. StartMonth = experience.StartMonth,
  42. EndYear = experience.EndYear,
  43. EndMonth = experience.EndMonth,
  44. Experience = experience.Experience
  45. }).ToList();
  46. studentExperienceList.ForEach(x => this.SetNewStatus(x));
  47. UnitOfWork.AddRange(studentExperienceList);
  48. UnitOfWork.Commit();
  49. }
  50. }
  51. }