public static IQueryable <UserProfile> PromptLearner <TEntity>(this ModelSource <TEntity> models, bool includeTrial = false) where TEntity : class, new() { IQueryable <UserRole> roleItems = models.GetTable <UserRole>(); IQueryable <UserRoleAuthorization> authItems = models.GetTable <UserRoleAuthorization>(); if (includeTrial) { roleItems = roleItems.Where(r => r.RoleID == (int)Naming.RoleID.Learner || r.RoleID == (int)Naming.RoleID.Preliminary || r.RoleID == (int)Naming.RoleID.Assistant); authItems = authItems.Where(r => r.RoleID == (int)Naming.RoleID.Learner || r.RoleID == (int)Naming.RoleID.Preliminary || r.RoleID == (int)Naming.RoleID.Assistant); } else { roleItems = roleItems.Where(r => r.RoleID == (int)Naming.RoleID.Learner); authItems = authItems.Where(r => r.RoleID == (int)Naming.RoleID.Learner); } var items = models.GetTable <UserProfile>() .Where(l => roleItems.Any(r => r.UID == l.UID) || authItems.Any(r => r.UID == l.UID)); return(items); }
public static IQueryable <RegisterLesson> PropmptReceivableTrialLesson <TEntity>(this ModelSource <TEntity> models) where TEntity : class, new() { var price = models.GetTable <LessonPriceType>().Where(p => p.ListPrice > 0 && p.Status == (int)Naming.DocumentLevelDefinition.體驗課程); return(models.GetTable <RegisterLesson>().Where(r => price.Any(p => p.PriceID == r.ClassLevel))); }
public static void RegisterMonthlyGiftLesson <TEntity>(this ModelSource <TEntity> models, int?[] uid = null) where TEntity : class, new() { var price = models.GetTable <LessonPriceType>().Where(l => l.IsWelfareGiftLesson != null).FirstOrDefault(); DateTime startDate = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1); DateTime endDate = startDate.AddMonths(1); if (price != null) { var items = models.GetTable <EmployeeWelfare>() .Where(m => m.MonthlyGiftLessons > 0) .Where(y => !y.UserProfile.RegisterLesson.Any(r => r.ClassLevel == price.PriceID && r.RegisterDate >= startDate && r.RegisterDate < endDate)); if (uid != null && uid.Length > 0) { items = items.Where(m => uid.Contains(m.UID)); } if (items.Count() > 0) { var table = models.GetTable <RegisterLesson>(); foreach (var item in items.ToList()) { var lastLesson = table.Where(r => r.UID == item.UID && r.ClassLevel == price.PriceID && r.RegisterDate < startDate && r.Attended != (int)Naming.LessonStatus.課程結束).FirstOrDefault(); var lesson = new RegisterLesson { UID = item.UID, RegisterDate = DateTime.Now, GroupingMemberCount = 1, Lessons = item.MonthlyGiftLessons.Value, ClassLevel = price.PriceID, IntuitionCharge = new IntuitionCharge { ByInstallments = 1, Payment = "Cash", FeeShared = 0 }, Attended = (int)Naming.LessonStatus.準備上課, AdvisorID = Settings.Default.DefaultCoach, AttendedLessons = 0, GroupingLesson = new GroupingLesson { } }; table.InsertOnSubmit(lesson); if (lastLesson != null) { lastLesson.Attended = (int)Naming.LessonStatus.課程結束; //lesson.Lessons += (lastLesson.Lessons - lastLesson.GroupingLesson.LessonTime.Count); } } models.SubmitChanges(); } } }
public static IQueryable <PDQQuestion> PromptDailyQuestion <TEntity>(this ModelSource <TEntity> models) where TEntity : class, new() { return(models.GetTable <PDQQuestion>() .Where(q => q.GroupID == 6) .Join(models.GetTable <PDQQuestionExtension>().Where(t => !t.Status.HasValue), q => q.QuestionID, t => t.QuestionID, (q, t) => q)); }
public static IQueryable <CourseContract> RemainedLessonCount <TEntity>(this UserProfile profile, ModelSource <TEntity> models, out int remainedCount, out IQueryable <RegisterLesson> remainedItems, bool onlyAttended = false) where TEntity : class, new() { var items = models.GetTable <RegisterLesson>() .Where(l => l.LessonPriceType.Status != (int)Naming.DocumentLevelDefinition.自主訓練) .Where(r => r.UID == profile.UID) .OrderByDescending(r => r.RegisterID); var currentLessons = items.Where(i => i.Attended != (int)Naming.LessonStatus.課程結束); remainedItems = currentLessons; var contractItems = currentLessons.Join(models.GetTable <RegisterLessonContract>(), r => r.RegisterID, c => c.RegisterID, (r, c) => c) .Join(models.GetTable <CourseContract>(), c => c.ContractID, n => n.ContractID, (c, n) => n); var familyLessons = contractItems.Where(c => c.CourseContractType.ContractCode == "CFA") .Join(models.GetTable <RegisterLessonContract>(), c => c.ContractID, r => r.ContractID, (c, r) => r) .Join(models.GetTable <RegisterLesson>(), c => c.RegisterID, r => r.RegisterID, (c, r) => r); int totalLessons = currentLessons.Sum(c => (int?)c.Lessons) ?? 0; int attendedLessons = currentLessons.Sum(c => (int?)c.AttendedLessons) ?? 0; int attendance; if (onlyAttended) { attendance = currentLessons.Sum(c => (int?)c.GroupingLesson.LessonTime.Count(l => l.LessonAttendance != null)) ?? 0; } else { attendance = currentLessons.Sum(c => (int?)c.GroupingLesson.LessonTime.Count()) ?? 0; } if (familyLessons.Count() > 0) { var exceptFamily = currentLessons.Where(r => r.RegisterLessonContract == null || r.RegisterLessonContract.CourseContract.CourseContractType.ContractCode != "CFA"); if (onlyAttended) { remainedCount = totalLessons - (exceptFamily.Sum(c => c.AttendedLessons) ?? 0) - (exceptFamily.Where(c => c.RegisterGroupID.HasValue).Sum(c => (int?)c.GroupingLesson.LessonTime.Count(l => l.LessonAttendance != null)) ?? 0) - (familyLessons.Sum(c => c.AttendedLessons) ?? 0) - (familyLessons.Where(c => c.RegisterGroupID.HasValue).Sum(c => (int?)c.GroupingLesson.LessonTime.Count(l => l.LessonAttendance != null)) ?? 0); } else { remainedCount = totalLessons - (exceptFamily.Sum(c => c.AttendedLessons) ?? 0) - (exceptFamily.Where(c => c.RegisterGroupID.HasValue).Sum(c => (int?)c.GroupingLesson.LessonTime.Count()) ?? 0) - (familyLessons.Sum(c => c.AttendedLessons) ?? 0) - (familyLessons.Where(c => c.RegisterGroupID.HasValue).Sum(c => (int?)c.GroupingLesson.LessonTime.Count()) ?? 0); } } else { remainedCount = totalLessons - attendedLessons - attendance; } return(contractItems); }
public static void ProcessInvoiceToGov() { if (Interlocked.Increment(ref __InvoiceBusyCount) == 1) { ThreadPool.QueueUserWorkItem(t => { try { using (var models = new ModelSource <UserProfile>()) { do { IQueryable <InvoiceItem> items = models.GetTable <InvoiceItemDispatch>() .Select(d => d.InvoiceItem); if (items.Count() > 0) { foreach (var item in items.ToArray()) { String fileName = Path.Combine(C0401Outbound, item.TrackCode + item.No + ".xml"); item.CreateC0401().ConvertToXml().Save(fileName); models.ExecuteCommand("delete InvoiceItemDispatch where InvoiceID={0}", item.InvoiceID); } } var cancelledItems = models.GetTable <InvoiceCancellationDispatch>() .Select(d => d.InvoiceCancellation); if (cancelledItems.Count() > 0) { foreach (var item in cancelledItems.Select(c => c.InvoiceItem).ToArray()) { String fileName = Path.Combine(C0501Outbound, item.TrackCode + item.No + ".xml"); item.CreateC0501().ConvertToXml().Save(fileName); models.ExecuteCommand("delete InvoiceCancellationDispatch where InvoiceID={0}", item.InvoiceID); } } var allowanceItems = models.GetTable <InvoiceAllowanceDispatch>() .Select(d => d.InvoiceAllowance); if (allowanceItems.Count() > 0) { foreach (var item in allowanceItems.ToArray()) { String fileName = Path.Combine(D0401Outbound, item.AllowanceNumber + ".xml"); item.CreateD0401().ConvertToXml().Save(fileName); models.ExecuteCommand("delete InvoiceAllowanceDispatch where AllowanceID={0}", item.AllowanceID); } } } while (Interlocked.Decrement(ref __InvoiceBusyCount) > 0); } } catch (Exception ex) { ApplicationLogging.LoggerFactory.CreateLogger(typeof(TaskExtensionMethods)) .LogError(ex, ex.Message); } }); } }
public static IQueryable <PDQGroup> GetBonusPromotion <TEntity>(this ModelSource <TEntity> models) where TEntity : class, new() { return(models.GetTable <PDQGroup>().Join( models.GetTable <PDQQuestion>().Join( models.GetTable <PDQQuestionExtension>() .Where(x => x.AwardingAction.HasValue), q => q.QuestionID, x => x.QuestionID, (q, x) => q), g => g.GroupID, q => q.GroupID, (g, q) => g)); }
public static IQueryable <CoachMonthlySalary> InquireMonthlySalary <TEntity>(this AchievementQueryViewModel viewModel, ModelSource <TEntity> models) where TEntity : class, new() { IQueryable <CoachMonthlySalary> items = models.GetTable <Settlement>() .Where(s => s.SettlementDate >= viewModel.AchievementDateFrom.Value.AddMonths(1) && s.SettlementDate < viewModel.AchievementDateTo.Value.AddMonths(1)) .Join(models.GetTable <CoachMonthlySalary>(), s => s.SettlementID, c => c.SettlementID, (s, c) => c); return(items); }
public static IQueryable <CourseContract> FilterByUnpaidContract <TEntity>(this IQueryable <CourseContract> contractItems, ModelSource <TEntity> models) where TEntity : class, new() { var items = models.GetTable <ContractPayment>() .Join(models.GetTable <Payment>().Where(p => p.VoidPayment == null), c => c.PaymentID, p => p.PaymentID, (c, p) => c); return(contractItems .Join(models.GetTable <CourseContractExtension>().Where(t => t.Version.HasValue), c => c.ContractID, t => t.ContractID, (c, t) => c) .Where(c => !items.Any(t => t.ContractID == c.ContractID))); }
public static LessonPriceType ContractOriginalSeriesPrice <TEntity>(this CourseContract item, ModelSource <TEntity> models) where TEntity : class, new() { var seriesItem = models.GetTable <V_LessonUnitPrice>() .Where(p => p.DurationInMinutes == item.LessonPriceType.DurationInMinutes) .Where(p => p.BranchID == item.LessonPriceType.BranchID) .Join(models.GetTable <LessonPriceType>(), p => p.PriceID, s => s.PriceID, (p, s) => s) .OrderByDescending(s => s.PriceID); return(seriesItem.FirstOrDefault()); }
public static IQueryable <CourseContractPayment> QueryContractPayment <TEntity>(this IQueryable <CourseContract> items, ModelSource <TEntity> models) where TEntity : class, new() { var dataItems = items.GroupJoin(models.GetTable <ContractPayment>() .Join(models.GetTable <Payment>().FilterByEffective(), c => c.PaymentID, p => p.PaymentID, (c, p) => new { c.ContractID, p.PayoffAmount }), t => t.ContractID, a => a.ContractID, (t, a) => new CourseContractPayment { Contract = t, TotalPaidAmount = a.Sum(s => s.PayoffAmount) }); return(dataItems); }
public static IQueryable <ServingCoach> PromptEffectiveCoach <TEntity>(this ModelSource <TEntity> models, IQueryable <UserProfile> items = null) where TEntity : class, new() { if (items == null) { items = models.GetTable <UserProfile>(); } items = items.Where(u => u.LevelID == (int)Naming.MemberStatusDefinition.Checked); return(models.GetTable <ServingCoach>() .Where(c => c.LevelID > (int)Naming.ProfessionLevelDefinition.Preliminary) .Join(items, c => c.CoachID, u => u.UID, (c, u) => c)); }
public static IQueryable <CourseContractRevision> PromptContractCauseForEnding <TEntity>(this UserProfile profile, ModelSource <TEntity> models, out IQueryable <CourseContract> unpaidOverdueItems, DateTime?dateFrom = null, DateTime?dateTo = null) where TEntity : class, new() { IQueryable <CourseContract> contracts = models.GetTable <CourseContract>(); if (profile.IsSysAdmin() || profile.IsAssistant() || profile.IsOfficer()) { } else if (profile.IsManager() || profile.IsViceManager()) { contracts = contracts .Join(models.GetTable <CourseContractExtension>() .Join(models.GetTable <BranchStore>() .Where(b => b.ManagerID == profile.UID || b.ViceManagerID == profile.UID), c => c.BranchID, b => b.BranchID, (c, b) => c), c => c.ContractID, e => e.ContractID, (c, e) => c); } else { contracts = contracts.Where(c => false); } unpaidOverdueItems = contracts .Where(c => c.Status == (int)Naming.CourseContractStatus.已終止) .Where(c => c.Subject == "已自動終止"); IQueryable <CourseContract> items = models.GetTable <CourseContract>() .Where(c => c.EffectiveDate.HasValue); if (dateFrom.HasValue) { items = items.Where(c => c.EffectiveDate >= dateFrom); unpaidOverdueItems = unpaidOverdueItems.Where(c => c.ValidTo >= dateFrom); } if (dateTo.HasValue) { items = items.Where(c => c.EffectiveDate < dateTo); unpaidOverdueItems = unpaidOverdueItems.Where(c => c.ValidTo < dateTo); } var revision = models.GetTable <CourseContractRevision>() .Where(r => r.Reason == "終止") .Where(r => r.CauseForEnding.HasValue) .Join(items, r => r.RevisionID, c => c.ContractID, (r, c) => r) .Join(contracts, r => r.OriginalContract, c => c.ContractID, (r, c) => r); return(revision); }
public static void UpdateExerciseGameContestant(this ExerciseGameContestant contestant) { if (contestant == null) { return; } ThreadPool.QueueUserWorkItem(t => { try { using (var models = new ModelSource <UserProfile>()) { if (contestant.Status == (int)Naming.GeneralStatus.Failed) { models.ExecuteCommand(@"UPDATE ExerciseGameRank SET RankingScore = NULL, Rank = NULL WHERE (UID = {0})", contestant.UID); } foreach (var item in models.GetTable <ExerciseGameItem>()) { models.RefreshExerciseGameRank(item.ExerciseID); } models.RefreshPersonalRank(); } } catch (Exception ex) { ApplicationLogging.LoggerFactory.CreateLogger(typeof(ExerciseGameExtensionMethods)) .LogError(ex, ex.Message); } }); }
private void checkD0401(ModelSource <UserProfile> models, String storePath, Naming.GeneralStatus status) { try { if (!Directory.Exists(storePath)) { return; } var items = models.GetTable <InvoiceAllowance>(); String archieve = storePath + ".zip"; foreach (var f in Directory.EnumerateFiles(storePath, "*.xml", SearchOption.AllDirectories)) { String fileName = Path.GetFileNameWithoutExtension(f); var item = items.Where(c => c.AllowanceNumber == fileName).FirstOrDefault(); if (item != null && item.InvoiceAllowanceDispatchLog == null) { item.InvoiceAllowanceDispatchLog = new InvoiceAllowanceDispatchLog { DispatchDate = DateTime.Now, Status = (int)status }; models.SubmitChanges(); } storeFile(archieve, f); } } catch (Exception ex) { Logger.Error(ex); } }
public static void CheckExerciseGameRank(this ExerciseGameResult resultItem) { ThreadPool.QueueUserWorkItem(t => { try { using (var models = new ModelSource <UserProfile>()) { var table = models.GetTable <ExerciseGameRank>(); var item = table.Where(r => r.UID == resultItem.UID && r.ExerciseID == resultItem.ExerciseID).FirstOrDefault(); if (item == null) { item = new ExerciseGameRank { UID = resultItem.UID, ExerciseID = resultItem.ExerciseID, }; table.InsertOnSubmit(item); } if (!item.RecordID.HasValue || item.ExerciseGameResult.TestDate < DateTime.Today.AddMonths(-3) || item.ExerciseGameResult.Score < resultItem.Score) { item.RecordID = resultItem.TestID; models.SubmitChanges(); resultItem.ExerciseID.UpdateExerciseGameRank(); } } } catch (Exception ex) { Logger.Error(ex); } }); }
public static IQueryable <RegisterLesson> PromptMemberExerciseRegisterLesson <TEntity>(this ModelSource <TEntity> models, IQueryable <RegisterLesson> items = null) where TEntity : class, new() { if (items == null) { items = models.GetTable <RegisterLesson>(); } var staff = models.GetTable <UserRoleAuthorization>().Where(a => Naming.StaffRole.Contains(a.RoleID)); items = items.Where(r => staff.Any(s => s.UID == r.UID)); //items = items.Join(models.GetTable<LessonPriceType>() // .Where(p => p.Status == (int)Naming.LessonPriceStatus.教練PI || p.IsWelfareGiftLesson != null), // r => r.ClassLevel, p => p.PriceID, (r, p) => r); return(items); }
public static IQueryable <UserEvent> PromptMemberEvents <TEntity>(this ModelSource <TEntity> models, UserProfile profile) where TEntity : class, new() { return(models.GetTable <UserEvent>() .Where(e => e.EventType == 1) .Where(t => t.UID == profile.UID || t.GroupEvent.Any(g => g.UID == profile.UID))); }
public static IQueryable <CourseContractRevision> PromptEffectiveRevision <TEntity>(this ModelSource <TEntity> models, DateTime?dateFrom, DateTime?dateTo) where TEntity : class, new() { IQueryable <CourseContract> items = models.GetTable <CourseContract>(); if (dateFrom.HasValue) { items = items.Where(c => c.EffectiveDate >= dateFrom); } if (dateTo.HasValue) { items = items.Where(c => c.EffectiveDate < dateTo); } return(models.GetTable <CourseContractRevision>() .Join(models.PromptEffectiveContract(), r => r.OriginalContract, c => c.ContractID, (r, c) => r) .Join(items, r => r.RevisionID, c => c.ContractID, (r, c) => r)); }
public static UserGuideEvent CheckUserGuideEvent <TEntity>(this UserProfile profile, ModelSource <TEntity> models, bool includeAfterToday = false) where TEntity : class, new() { var items = models.GetTable <UserEvent>().Where(v => v.StartDate <= DateTime.Today && v.UID == profile.UID) .Join(models.GetTable <SystemEventBulletin>(), v => v.SystemEventID, b => b.EventID, (v, b) => v); if (items.Count() > 0) { return(new UserGuideEvent { GuideEventList = items, Profile = profile, }); } return(null); }
protected virtual InvoiceException checkBusiness() { _seller = _mgr.GetTable <Organization>().Where(o => o.CompanyID == _invItem.SellerID).FirstOrDefault(); if (_seller == null) { _seller = _mgr.GetTable <Organization>().Where(o => o.ReceiptNo == _invItem.SellerReceiptNo).FirstOrDefault(); } if (_seller == null) { return(new InvoiceException(String.Format("營業人資料錯誤,統一編號:{0}", _invItem.SellerReceiptNo))); } if (String.IsNullOrEmpty(_invItem.BuyerReceiptNo)) { _invItem.BuyerReceiptNo = "0000000000"; } else if (_invItem.BuyerReceiptNo != "0000000000") { if (!Regex.IsMatch(_invItem.BuyerReceiptNo, "^[0-9]{8}$")) { return(new InvoiceException(String.Format("公司統一編號錯誤:{0}", _invItem.BuyerReceiptNo)) { RequestName = "BuyerReceiptNo" }); } else if (!_invItem.BuyerReceiptNo.CheckRegno()) { return(new InvoiceException(String.Format("公司統一編號錯誤:{0}", _invItem.BuyerReceiptNo)) { RequestName = "BuyerReceiptNo" }); } } if (String.IsNullOrEmpty(_invItem.RandomNo)) { _invItem.RandomNo = String.Format("{0:ffff}", DateTime.Now); //ValueValidity.GenerateRandomCode(4) } else if (!Regex.IsMatch(_invItem.RandomNo, "^[0-9]{4}$")) { return(new InvoiceException(String.Format("交易隨機碼應由4位數值構成,上傳資料:{0}", _invItem.RandomNo))); } return(checkBusinessDetails()); }
public static IQueryable <CourseContract> GetEarlyUnpaidInstallments <TEntity>(this CourseContract contract, ModelSource <TEntity> models) where TEntity : class, new() { var items = models.GetTable <CourseContract>() .Where(c => c.InstallmentID == contract.InstallmentID) .Where(c => c.ContractID < contract.ContractID); return(items.FilterByUnpaidContract(models)); }
public static IQueryable <V_Tuition> InquireAchievementTuition <TEntity>(this AchievementQueryViewModel viewModel, ModelSource <TEntity> models) where TEntity : class, new() { if (!viewModel.AchievementDateFrom.HasValue) { if (!String.IsNullOrEmpty(viewModel.AchievementYearMonthFrom)) { viewModel.AchievementDateFrom = DateTime.ParseExact(viewModel.AchievementYearMonthFrom, "yyyy/MM", System.Globalization.CultureInfo.CurrentCulture); } else { viewModel.AchievementDateFrom = DateTime.Today.FirstDayOfMonth(); } } if (!viewModel.AchievementDateTo.HasValue) { if (!String.IsNullOrEmpty(viewModel.AchievementYearMonthTo)) { viewModel.AchievementDateTo = DateTime.ParseExact(viewModel.AchievementYearMonthTo, "yyyy/MM", System.Globalization.CultureInfo.CurrentCulture).AddMonths(1); } else { viewModel.AchievementDateTo = viewModel.AchievementDateFrom.Value.AddMonths(1); } } IQueryable <V_Tuition> items = models.GetTable <V_Tuition>(); if (viewModel.CoachID.HasValue) { items = items.Where(c => c.AttendingCoach == viewModel.CoachID); } if (viewModel.ByCoachID != null && viewModel.ByCoachID.Length > 0) { items = items.Where(c => viewModel.ByCoachID.Contains(c.AttendingCoach)); } if (viewModel.BranchID.HasValue) { items = items.Where(c => c.BranchID == viewModel.BranchID); } if (viewModel.AchievementDateFrom.HasValue) { items = items.Where(c => c.ClassTime >= viewModel.AchievementDateFrom); } if (viewModel.AchievementDateTo.HasValue) { items = items.Where(c => c.ClassTime < viewModel.AchievementDateTo); } return(items); }
public static IQueryable <CourseContract> PromptAccountingContract <TEntity>(this ModelSource <TEntity> models) where TEntity : class, new() { var items = models.GetTable <CourseContract>() .Where(c => c.CourseContractRevision == null) .Where(c => c.Status == (int)Naming.CourseContractStatus.已生效 || c.Status == (int)Naming.CourseContractStatus.已過期); return(items); }
public static MonthlyIndicator AssertMonthlyIndicator <TEntity>(this MonthlyIndicatorQueryViewModel viewModel, ModelSource <TEntity> models) where TEntity : class, new() { var item = models.GetTable <MonthlyIndicator>().Where(i => i.PeriodID == viewModel.PeriodID).FirstOrDefault(); if (item != null) { return(item); } item = models.GetTable <MonthlyIndicator>().Where(i => (i.Year == viewModel.Year && i.Month == viewModel.Month)).FirstOrDefault(); if (item != null) { return(item); } item = models.InitializeMonthlyIndicator(viewModel.Year.Value, viewModel.Month.Value); return(item); }
public IViewComponentResult LoadCompleteExercisePurposeItems(ExercisePurposeViewModel viewModel) { ViewBag.ViewModel = viewModel; var items = models.GetTable <PersonalExercisePurposeItem>() .Where(p => p.UID == viewModel.UID) .Where(p => p.CompleteDate.HasValue) .OrderByDescending(p => p.CompleteDate); return(View("~/Views/LearnerProfile/Module/TrainingMilestoneItems.cshtml", items)); }
public static IQueryable <InvoiceAllowance> ExtractPaymentAllowance <TEntity>(this IQueryable <Payment> items, ModelSource <TEntity> models, IQueryable <InvoiceAllowance> filterItems = null) where TEntity : class, new() { if (filterItems == null) { filterItems = models.GetTable <InvoiceAllowance>(); } return(items.Join(filterItems, p => p.AllowanceID, a => a.AllowanceID, (p, a) => a)); }
public static IQueryable <RegisterLesson> FilterByUnpaidLesson <TEntity>(this ModelSource <TEntity> models, IQueryable <RegisterLesson> items = null) where TEntity : class, new() { if (items == null) { items = models.GetTable <RegisterLesson>(); } return(items.Where(r => r.IntuitionCharge.TuitionInstallment.Count == 0 || !r.IntuitionCharge.TuitionInstallment.Any(t => t.Payment.VoidPayment == null || t.Payment.VoidPayment.Status != (int)Naming.CourseContractStatus.已生效))); }
public static IQueryable <CourseContract> FilterByExpiringContract <TEntity>(this IQueryable <CourseContract> items, ModelSource <TEntity> models) where TEntity : class, new() { var revisionID = models.GetTable <CourseContractRevision>().Where(r => r.Reason == "展延") .Select(r => r.RevisionID); return(items .Where(c => !c.RegisterLessonContract.Any(r => r.RegisterLesson.Attended == (int)Naming.LessonStatus.課程結束)) .Where(c => c.Expiration < DateTime.Today.AddMonths(1)) .Where(c => !revisionID.Any(r => r == c.ContractID))); }
public static IQueryable <TuitionAchievement> GetPaymentAchievement <TEntity>(this IQueryable <Payment> items, ModelSource <TEntity> models, IQueryable <TuitionAchievement> filterItems = null) where TEntity : class, new() { if (filterItems == null) { filterItems = models.GetTable <TuitionAchievement>(); } return(items //.FilterByEffective() .Join(filterItems, p => p.PaymentID, t => t.InstallmentID, (p, t) => t)); }