// Copyright © Selmo Technology GmbH. All Rights Reserved

using SelmoStudio.Hmi.Server.AuditTrail.Model;
using SelmoStudio.Hmi.Server.TestSetup;

namespace SelmoStudio.Hmi.Server.AuditTrail.Service
{
    internal class AuditTrailService : IAuditTrailService
    {
        private AuditTrailClass _auditTrail;

        public AuditTrailService()
        {
            _auditTrail = GetTestAuditTrailWithEntries();
        }

        public Task<AuditTrailClass> GetAsync()
        {
            return Task.FromResult(_auditTrail);
        }

        public void ClearEntries(IList<AuditTrailEntry> entries)
        {
            _auditTrail.Entries.RemoveAll(item => entries.Contains(item));
        }

        public void Reload()
        {
            _auditTrail = GetTestAuditTrailWithEntries();
        }

        private AuditTrailClass GetTestAuditTrailWithEntries()
        {
            return new TestAuditTrailBuilder().WithEntries(6).Build();
        }
    }
}