using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using PowerMatterServiceReference; using Microsoft.AspNetCore.Cors; namespace Winsoft.GOV.PowerMatter.Restful.Controllers { [Route("api/[controller]")] [EnableCors("any")] public class PowerMatterController : Controller { IPowerMettersService _powerMatterService; public PowerMatterController(IPowerMettersService powerMatterService) { _powerMatterService = powerMatterService; } [HttpGet("getByBranch/{c:int}/{guid}")] [Produces(typeof(List))] public async Task Get(County c, string guid) { List ps = await _powerMatterService.GetPowerMattersByBranchGuidExAsync(guid, c); if (ps == null) ps = new List(); return Ok(ps); } [HttpGet("detail/{c:int}/{ql_inner_code}")] [Produces(typeof(PowerMattersDetail))] public async Task GetDetail(County c, string ql_inner_code) { PowerMattersDetail pd = await _powerMatterService.GetPowerMattersDetailByRowIDExAsync(ql_inner_code, c); if (pd == null) return BadRequest(); return Ok(pd); } } }