using LiangLiSystem.Services.Helpers; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using System; using System.Collections.Generic; using System.Linq; using System.Security.Claims; using System.Threading.Tasks; using Traffic.Data.ViewModels; using Traffic.Service.Interfaces; namespace Traffic.Api.Controllers { [Route("api/malfunction")] [Authorize] [ApiController] public class MalfunctionController : ControllerBase { private readonly IMalfunctionService _service; public MalfunctionController(IMalfunctionService service) { _service = service; } ///// ///// 取得設備狀態 ///// ///// //[HttpGet("old")] //public IActionResult GetMalfunctionsOld() //{ // try // { // var userIdentity = (ClaimsIdentity)User.Identity; // var userid = new ParserForUserFromClaim(userIdentity).GetUserId(); // var result = new Response(); // result.Result = _service.GetMalfunctionsOld(userid); // return Ok(result); // } // catch (Exception ex) // { // return BadRequest(); // } //} /// /// 取得設備狀態 /// /// [HttpGet("")] public IActionResult GetMalfunctions() { try { var userIdentity = (ClaimsIdentity)User.Identity; var userid = new ParserForUserFromClaim(userIdentity).GetUserId(); var result = new Response(); result.Result = _service.GetMalfunctions(userid); return Ok(result); } catch (Exception ex) { return BadRequest(); } } } }