FIC_Solar/SolarPower/Controllers/RoleController.cs
2021-06-09 15:03:24 +08:00

52 lines
1.6 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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<RoleController>
{
private readonly IRoleRepository roleRepository;
public RoleController(IRoleRepository roleRepository) : base()
{
this.roleRepository = roleRepository;
}
public IActionResult Index()
{
return View();
}
/// <summary>
/// 取得下拉式公司選單須為Deleted: 0
/// </summary>
/// <returns></returns>
[HttpGet]
public async Task<ApiResult<List<RoleSelectItemList>>> GetRoleSelectOptionListAsync(int companyId)
{
ApiResult<List<RoleSelectItemList>> apiResult = new ApiResult<List<RoleSelectItemList>>();
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;
}
}
}