TeacherTypePaymentFormulaDAL.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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.PaymentManage;
  7. using System.Linq.Expressions;
  8. using Bowin.Common.Linq;
  9. using EMIS.Entities;
  10. using EMIS.ViewModel;
  11. namespace EMIS.DataLogic.PaymentManage
  12. {
  13. public class TeacherTypePaymentFormulaDAL
  14. {
  15. public PaymentFormulaRepository PaymentFormulaRepository { get; set; }
  16. public TeacherTypePaymentFormulaRepository TeacherTypePaymentFormulaRepository { get; set; }
  17. public DictionaryItemRepository DictionaryItemRepository { get; set; }
  18. public IQueryable<TeacherTypePaymentFormulaView> GetTeacherTypePaymentFormulaViewQueryable(Expression<Func<Sys_DictionaryItem, bool>> exp)
  19. {
  20. var defaultPaymentFormula = PaymentFormulaRepository.GetSingle(x => x.IsDefault == true);
  21. var teacherTypeExpression = exp.And(x => x.DictionaryCode == typeof(CF_TeacherType).Name);
  22. var q = (from teacherType in DictionaryItemRepository.GetList(teacherTypeExpression)
  23. join setting in TeacherTypePaymentFormulaRepository.Entities on teacherType.Value equals setting.TeacherType into dsetting
  24. from setting in dsetting.DefaultIfEmpty()
  25. select new TeacherTypePaymentFormulaView
  26. {
  27. TeacherType = teacherType.Value,
  28. PaymentFormulaID = setting == null ? defaultPaymentFormula.PaymentFormulaID : setting.PaymentFormulaID,
  29. StudentCountRateFormunla = setting == null ? defaultPaymentFormula.StudentCountRateFormunla : setting.TP_PaymentFormula.StudentCountRateFormunla,
  30. PaymentFormula = setting == null? defaultPaymentFormula.PaymentFormula : setting.TP_PaymentFormula.PaymentFormula,
  31. OrderNo = teacherType.OrderNo
  32. });
  33. return q;
  34. }
  35. public IQueryable<PaymentFormlulaView> GetPaymentFormulaViewQueryable()
  36. {
  37. var q = (from formula in PaymentFormulaRepository.Entities
  38. select new PaymentFormlulaView
  39. {
  40. PaymentFormulaID = formula.PaymentFormulaID,
  41. Name = formula.Name,
  42. StudentCountRateFormunla = formula.StudentCountRateFormunla,
  43. PaymentFormula = formula.PaymentFormula,
  44. IsDefault = formula.IsDefault
  45. });
  46. return q;
  47. }
  48. }
  49. }