using FrontendWebApi.Models; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; using Repository.BackendRepository.Interface; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; namespace FrontendWebApi.Controllers { public class EmergencyRecordController : MyBaseController { private readonly IBackendRepository backendRepository; public EmergencyRecordController(IBackendRepository backendRepository) { this.backendRepository = backendRepository; } public IActionResult Index() { return View(); } [HttpPost] public async Task>> DisasterList() { ApiResult> apiResult = new ApiResult>(); List Variable = new List(); try { var sqlString = @$"select system_value as Value, system_key as Name from variable a where a.system_type = 'disaster' and a.deleted = 0"; Variable = await backendRepository.GetAllAsync(sqlString); apiResult.Code = "0000"; apiResult.Data = Variable; } catch (Exception exception) { apiResult.Code = "9999"; apiResult.Msg = "系統內部錯誤,請聯絡管理者。"; Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); } return apiResult; } } }