using System.Collections.Generic;
using Datory;
using GxPress.Repository.Interface.Vip;
using AutoMapper;
using Microsoft.Extensions.Options;
using GxPress.Common.AppOptions;
using GxPress.Common.Tools;

namespace GxPress.Repository.Implement.Vip
{
    public class VipRepository : IVipRepository
    {
        private readonly Repository<Entity.Vip.Vip> _repository;
        private readonly IMapper _mapper;

        public VipRepository(IOptionsMonitor<DatabaseOptions> dbOptionsAccessor, IMapper mapper)
        {
            var databaseType = StringUtils.ToEnum<DatabaseType>(dbOptionsAccessor.CurrentValue.DatabaseType, DatabaseType.MySql);
            var database = new Database(databaseType, dbOptionsAccessor.CurrentValue.ConnectionString);
            _repository = new Repository<Entity.Vip.Vip>(database);
            _mapper = mapper;
        }

        public IDatabase Database => _repository.Database;
        public string TableName => _repository.TableName;
        public List<TableColumn> TableColumns => _repository.TableColumns;
    }
}