using Microsoft.AspNetCore.Mvc;
using Nirvana.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Waste.Application;
using Waste.Domain;

namespace Waste.Web.Entry.Pages.Shared.Components.Menu
{
    public class MenuViewComponent : ViewComponent
    {
        private readonly ISystemService _systemService;
        public MenuViewComponent(ISystemService systemService)
        {
            _systemService = systemService;
        }
        public async Task<IViewComponentResult> InvokeAsync()
        {
            var currentuser = OperatorProvider.Provider.GetCurrent();
            var data = new List<W_Menu>();
            data = currentuser.IsSuper
                 ? await _systemService.GetMenuListAsync()
                 : await _systemService.GetMenuListAsync(currentuser.RoleId);
            return View(data);
        }
    }
}
