using System;
using System.Security.Principal;
using Microsoft.Extensions.Logging;
using Quadarax.Foundation.Core.Business.Interface;
using Quadarax.Foundation.Core.Data.Interface.Entity;
using Quadarax.Foundation.Core.Data.Interface.Entity.Dto;

namespace Quadarax.Foundation.Core.Business
{
    public abstract class AbstractService : IService
    {
        #region *** Properties ***
        protected ILogger<AbstractService> Log { get; }
        protected IPrincipal CurrentPrincipal { get; }
        #endregion

        #region *** Constructors ***
        protected AbstractService(IPrincipal currentPrincipal, ILoggerFactory logger)
        {
            Log = logger.CreateLogger<AbstractService>();

            if (currentPrincipal == null)
            {
                var genericIdentity = new GenericIdentity("genericIdentity");
                currentPrincipal = new GenericPrincipal(genericIdentity, new string[] {});
            }
            CurrentPrincipal = currentPrincipal;
            Log.LogTrace($"Service '{GetType().Name}' [Hash:{GetHashCode()}] initialized.");
        }
        #endregion

        #region *** Public Operations ***
        public IResult Test()
        {
            return new ResultPlain();
        }

        #endregion
    }
}
