using System; using System.Collections.Generic; using System.Linq; using System.Text; using EMIS.DataLogic.Repositories; using EMIS.ViewModel.PaymentManage; using System.Linq.Expressions; using Bowin.Common.Linq; using EMIS.Entities; using EMIS.ViewModel; namespace EMIS.DataLogic.PaymentManage { public class TeacherTypePaymentFormulaDAL { public PaymentFormulaRepository PaymentFormulaRepository { get; set; } public TeacherTypePaymentFormulaRepository TeacherTypePaymentFormulaRepository { get; set; } public DictionaryItemRepository DictionaryItemRepository { get; set; } public IQueryable GetTeacherTypePaymentFormulaViewQueryable(Expression> exp) { var defaultPaymentFormula = PaymentFormulaRepository.GetSingle(x => x.IsDefault == true); var teacherTypeExpression = exp.And(x => x.DictionaryCode == typeof(CF_TeacherType).Name); var q = (from teacherType in DictionaryItemRepository.GetList(teacherTypeExpression) join setting in TeacherTypePaymentFormulaRepository.Entities on teacherType.Value equals setting.TeacherType into dsetting from setting in dsetting.DefaultIfEmpty() select new TeacherTypePaymentFormulaView { TeacherType = teacherType.Value, PaymentFormulaID = setting == null ? defaultPaymentFormula.PaymentFormulaID : setting.PaymentFormulaID, StudentCountRateFormunla = setting == null ? defaultPaymentFormula.StudentCountRateFormunla : setting.TP_PaymentFormula.StudentCountRateFormunla, PaymentFormula = setting == null? defaultPaymentFormula.PaymentFormula : setting.TP_PaymentFormula.PaymentFormula, OrderNo = teacherType.OrderNo }); return q; } public IQueryable GetPaymentFormulaViewQueryable() { var q = (from formula in PaymentFormulaRepository.Entities select new PaymentFormlulaView { PaymentFormulaID = formula.PaymentFormulaID, Name = formula.Name, StudentCountRateFormunla = formula.StudentCountRateFormunla, PaymentFormula = formula.PaymentFormula, IsDefault = formula.IsDefault }); return q; } } }