using Microsoft.AspNet.Identity.EntityFramework;
using Sevomin.Models;
using Sevomin.Models.Helpers;
using System.Threading.Tasks;
using System.Web.Mvc;

namespace Sevomin.WebFrontend.Controllers
{
    public class HomeController : BaseController
    {
        public HomeController()
            : this(new SevominUserManager(new UserStore<User>(SevominDbContext.Current)))
        {
        }

        public HomeController(SevominUserManager userManager)
        {
            UserManager = userManager;
        }

        public SevominUserManager UserManager { get; private set; } 

        public async Task<ActionResult> Index()
        {
            if (!Request.IsAuthenticated)
                return View("Intro");
            else
            {
                User user = await UserManager.FindByNameAsync(User.Identity.Name);
                if (user is Avalin)                                    
                    return View("AvalinIndex");                
                else                
                    return View("DovominIndex");                                 
            }                
        }
			
    }
}