private async Task <SpfHistoryEntityState> LoadHistoryState(string id)
        {
            SpfHistoryEntityState entityHistoryState =
                await _dao.Get(id) ?? new SpfHistoryEntityState(id);

            return(entityHistoryState);
        }
        public async Task Handle(SpfRecordsPolled message)
        {
            string messageId = message.Id.ToLower();

            SpfHistoryEntityState entityHistory = await LoadHistoryState(messageId);

            List <string> records = new List <string>();

            message.Records?.Records.ForEach(x => records.AddRange(x.RecordsStrings));

            if (entityHistory.UpdateHistory(records, message.Timestamp))
            {
                await _dao.Save(entityHistory);
            }
        }
        public async Task Handle(DomainCreated message)
        {
            string messageId = message.Id.ToLower();

            SpfHistoryEntityState state = await _dao.Get(messageId);

            if (state == null)
            {
                state = new SpfHistoryEntityState(messageId);
                await _dao.Save(state);

                _log.LogInformation("Created SpfEntityHistory for {Id}.", messageId);
            }
            else
            {
                _log.LogWarning("Ignoring {EventName} as SpfEntityHistory already exists for {Id}.",
                                nameof(DomainCreated), messageId);
                ;
            }
        }