using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;

namespace EnotaryoPH.Web.Pages
{
    public class IndexModel : PageModel
    {
        private readonly ICurrentUserService _currentUserService;

        public IndexModel(ICurrentUserService currentUserService) => _currentUserService = currentUserService;

        public IActionResult OnGet()
        {
            if (_currentUserService.IsAuthenticated() == false)
            {
                return Page();
            }

            if (_currentUserService.GetRole() == "Principal")
            {
                return RedirectToPage("/Principal/Dashboard/Dashboard");
            }

            return Page();
        }
    }
}