using Aberwyn.Models;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

namespace Aberwyn.Controllers
{
    [Authorize(Roles = "Budget")]
    public class BudgetController : Controller
    {
        [Route("budget/{year:int}/{month:int}")]
        public IActionResult Index(int year, int month)
        {
            ViewBag.Year = year;
            ViewBag.Month = month;
            return View();
        }
        [Route("budget/list")]
        public IActionResult List()
        {
            return View();
        }

        [Route("budget/{name}")]
        public IActionResult Index(string name)
        {
            ViewBag.BudgetName = name;
            return View();
        }

        [Route("budget/elkostnad")]
        public IActionResult Elkostnad()
        {
            return View();
        }


        // För fallback när ingen månad/år anges
        [Route("budget")]
        public IActionResult Index()
        {
            var now = DateTime.Now;
            return RedirectToAction("Index", new { year = now.Year, month = now.Month });
        }


    }
}
