BranchController.cs 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Threading.Tasks;
  5. using Microsoft.AspNetCore.Mvc;
  6. using PowerMatterServiceReference;
  7. using Microsoft.AspNetCore.Cors;
  8. // For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
  9. namespace Winsoft.GOV.PowerMatter.Restful.Controllers
  10. {
  11. [Route("api/[controller]")]
  12. [EnableCors("any")]
  13. public class BranchController : Controller
  14. {
  15. IPowerMettersService _powerMatterService;
  16. public BranchController(IPowerMettersService powerMatterService)
  17. {
  18. _powerMatterService = powerMatterService;
  19. }
  20. // GET: api/values
  21. [HttpGet("all/{c:int}")]
  22. [Produces(typeof(List<Branch>))]
  23. public async Task<IActionResult> Get(County c)
  24. {
  25. List<Branch> bs = await _powerMatterService.GetBranchsExAsync(c);
  26. if (bs == null)
  27. bs = new List<Branch>();
  28. return Ok(bs);
  29. }
  30. }
  31. }