Esempio n. 1
0
 internal static Expression ContributionChange(
     ParameterExpression parm, CMSDataContext Db,
     DateTime? dt1,
     DateTime? dt2,
     CompareType op,
     double pct)
 {
     if (Db.CurrentUser == null || Db.CurrentUser.Roles.All(rr => rr != "Finance"))
         return AlwaysFalse(parm);
     var q = Db.GivingCurrentPercentOfFormer(dt1, dt2,
         op == CompareType.Greater ? ">" :
         op == CompareType.GreaterEqual ? ">=" :
         op == CompareType.Less ? "<" :
         op == CompareType.LessEqual ? "<=" :
         op == CompareType.Equal ? "=" : "<>", pct);
     var tag = Db.PopulateTemporaryTag(q.Select(pp => pp.Pid));
     Expression<Func<Person, bool>> pred = p => p.Tags.Any(t => t.Id == tag.Id);
     Expression expr = Expression.Invoke(pred, parm);
     return expr;
 }
Esempio n. 2
0
 internal static Expression RecentGivingAsPctOfPrevious(
     ParameterExpression parm, CMSDataContext Db,
     int Days,
     CompareType op,
     double pct)
 {
     var dt1 = DateTime.Today.AddDays(-Days * 2);
     var dt2 = DateTime.Today.AddDays(-Days);
     var q = Db.GivingCurrentPercentOfFormer(dt1, dt2, op == CompareType.Greater ? ">" : "<=", pct);
     var tag = Db.PopulateTemporaryTag(q.Select(pp => pp.Pid));
     Expression<Func<Person, bool>> pred = p => p.Tags.Any(t => t.Id == tag.Id);
     Expression expr = Expression.Invoke(pred, parm);
     return expr;
 }