public static int DoAllGiving(CMSDataContext Db) { int?GatewayId = MultipleGatewayUtils.GatewayId(Db, PaymentProcessTypes.RecurringGiving); int count = 0; if (GatewayId != null) { var q = from rg in Db.ManagedGivings where rg.NextDate < Util.Now.Date select rg; foreach (var rg in q) { rg.NextDate = rg.FindNextDate(Util.Now.Date); } var rgq = from rg in Db.ManagedGivings where rg.NextDate == Util.Now.Date select new { rg, rg.Person, rg.Person.RecurringAmounts, }; foreach (var i in rgq) { count += i.rg.DoGiving(Db); } } return(count); }