using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; using SolarPower.Models; using SolarPower.Models.Role; using SolarPower.Repository.Interface; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; namespace SolarPower.Controllers { public class RoleController : MyBaseController { private readonly IRoleRepository roleRepository; public RoleController(IRoleRepository roleRepository) : base() { this.roleRepository = roleRepository; } public IActionResult Index() { return View(); } /// /// 取得下拉式公司選單,須為Deleted: 0 /// /// [HttpGet] public async Task>> GetRoleSelectOptionListAsync(int companyId) { ApiResult> apiResult = new ApiResult>(); try { var roleSelectItemLists = await roleRepository.GetRoleSelectOptionListAsync(companyId); apiResult.Code = "0000"; apiResult.Data = roleSelectItemLists; } catch (Exception exception) { apiResult.Code = "9999"; Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); } apiResult.Msg = errorCode.GetString(apiResult.Code); return apiResult; } } }