tycg_carviolation_BE/Traffic.Api/Controllers/MalfunctionController.cs

72 lines
2.0 KiB
C#
Raw Normal View History

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;
}
///// <summary>
///// 取得設備狀態
///// </summary>
///// <returns></returns>
//[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();
// }
//}
/// <summary>
/// 取得設備狀態
/// </summary>
/// <returns></returns>
[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();
}
}
}
}