using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DotVVM.Framework.ViewModel;
using DotVVM.Framework.Hosting;
using Microsoft.AspNetCore.Identity;
using System.Threading.Tasks;
using ElectroShop.DAL.Entities;

namespace ElectroShop.ViewModels
{
    public class MasterPageViewModel : DotvvmViewModelBase
    {
        public string UserNameGlobal { get; set; }
        public List<string> ValidationErrors { get; set; }

        public override Task Init()
        {
            if (this.Context.HttpContext.User != null)
            {
                UserNameGlobal = this.Context.HttpContext.User.Identity.Name;
            }
            return base.Init();
        }

        public async Task SignOut()
        {
            await Context.GetAuthentication().SignOutAsync(IdentityConstants.ApplicationScheme);
            Context.RedirectToRoute("Default", null, false, false);

        }
    }
}
