using System;
using System.Security.Principal;
using System.Threading.Tasks;
using BO.AppServer.Data.Entity;
using BO.AppServer.Data.Repository;
using BO.AppServer.Metadata.Dto;
using  BO.AppServer.Business.Mapper;
using Microsoft.Extensions.Logging;
using Quadarax.Foundation.Core.Business;
using Quadarax.Foundation.Core.Data.Interface.Entity.Dto;

namespace BO.AppServer.Business.Services
{
    public class StatisticsService : AbstractService
    {
        #region *** Private fields ***
        protected StatisticRepo _repoStatistic;
        protected UserRepo _repoUser;
        #endregion

        #region *** Constructor & DI ***
        public StatisticsService(
            StatisticRepo repoStatistic,
            UserRepo repoUser,
            IPrincipal currentPrincipal,
            ILoggerFactory logger) : base(currentPrincipal, logger)
        {
            _repoStatistic = repoStatistic ?? throw new ArgumentNullException(nameof(repoStatistic));
            _repoUser = repoUser ?? throw new ArgumentNullException(nameof(repoUser));

        }
        #endregion

        #region *** Public Operations ***

        public async Task<ResultValueDto<StatisticsDto>> GetCurrent()
        {
            var current = _repoStatistic.GetCurrent();
            return new ResultValueDto<StatisticsDto>(current.Map<Statistic, StatisticsDto>());
        }

        #endregion
    }
}
