using Autofac;
using GreenTree.Nachtragsmanagement.Core.Domain.User;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GreenTree.Nachtragsmanagement.Core.Authentication
{
    public class UserContext
    {
        private User _currentUser;
        public User CurrentUser
        {
            get
            {
                if (_currentUser == null)
                {
                    var container = Singleton<Autofac.IContainer>.Instance;
                    var userHelper = container.Resolve<IUserHelper>();

                    _currentUser = userHelper.FromCookies();
                }

                return _currentUser;
            }
            set
            {
                _currentUser = value;
            }
        }
    }
}
