Exemplo n.º 1
0
        private static int UpdateSendGridAliasHistory(IEnumerable <PersonAlias> personAliases)
        {
            var personAliasesEnumerated = personAliases as IList <PersonAlias> ?? personAliases.ToList();

            if (!personAliasesEnumerated.Any())
            {
                return(0);
            }
            var now         = RockDateTime.Now;
            var rockContext = new RockContext();
            var personAliasHistoryService = new PersonAliasHistoryService(rockContext);
            int updated = 0;

            foreach (var personalias in personAliasesEnumerated)
            {
                var personAliasHistory = personAliasHistoryService.GetByPersonAliasId(personalias.Id);
                if (personAliasHistory != null)
                {
                    personAliasHistory.LastUpdated = now;
                }
                else
                {
                    personAliasHistory = new PersonAliasHistory
                    {
                        PersonAliasId = personalias.Id,
                        LastUpdated   = now
                    };
                    personAliasHistoryService.Add(personAliasHistory);
                }
                updated++;
            }
            rockContext.SaveChanges();
            return(updated);
        }
Exemplo n.º 2
0
        private static int AddToSendGridAliasHistory(IEnumerable <PersonAlias> personAliases)
        {
            var now         = RockDateTime.Now;
            var rockContext = new RockContext();
            var personAliasHistoryService = new PersonAliasHistoryService(rockContext);
            int synced = 0;

            foreach (var aliasId in personAliases)
            {
                var personAliasHistory = new PersonAliasHistory
                {
                    PersonAliasId = aliasId.Id,
                    LastUpdated   = now
                };
                personAliasHistoryService.Add(personAliasHistory);
                synced++;
            }
            rockContext.SaveChanges();
            return(synced);
        }