public async Task <TriggerResult> CheckLinkedSecurityUser(EntityModel model, List <dynamic> entities, TriggerExecutionContext context, dynamic options) { foreach (var entity in entities) { entity.Name = entity.FirstName + " " + entity.LastName; SecurityUser user = await SecurityUser.SelectByKey(entity.Id); if (user == null) { user = new SecurityUser() { Id = entity.Id, Name = entity.Name, Email = entity.Email }; await user.ApplyAsync(); } else { if (user.Name != entity.Name || user.Email != entity.Email) { user.StartTracking(); user.Name = entity.Name; user.Email = entity.Email; await user.ApplyAsync(); } } await EmployeeBusiness.CheckDefaultRole(user.Id, "Users"); } return(TriggerResult.Success()); }