新增註解 新增時間搜尋 新增車牌搜尋
This commit is contained in:
parent
53287bb390
commit
e210b04ef3
@ -21,7 +21,13 @@ namespace WebApi_data_value.Controllers
|
||||
_context = context;
|
||||
}
|
||||
|
||||
#region
|
||||
// GET: api/Parking_spaces_violation_total_table
|
||||
/// <summary>
|
||||
/// 獲取所有違規區域名稱
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
|
||||
[HttpGet]
|
||||
public async Task<ActionResult<IEnumerable<Parking_spaces_violation_total_table>>> Getparking_spaces_violation_total_table()
|
||||
{
|
||||
@ -31,7 +37,14 @@ namespace WebApi_data_value.Controllers
|
||||
}
|
||||
return await _context.parking_spaces_violation_total_table.ToListAsync();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
// GET: api/Parking_spaces_violation_total_table/5
|
||||
[HttpGet("{id}")]
|
||||
public async Task<ActionResult<Parking_spaces_violation_total_table>> GetParking_spaces_violation_total_table(string id)
|
||||
@ -49,7 +62,15 @@ namespace WebApi_data_value.Controllers
|
||||
|
||||
return parking_spaces_violation_total_table;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="parking_spaces_violation_total_table"></param>
|
||||
/// <returns></returns>
|
||||
// PUT: api/Parking_spaces_violation_total_table/5
|
||||
// To protect from overposting attacks, see https://go.microsoft.com/fwlink/?linkid=2123754
|
||||
[HttpPut("{id}")]
|
||||
@ -80,7 +101,15 @@ namespace WebApi_data_value.Controllers
|
||||
|
||||
return NoContent();
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="parking_spaces_violation_total_table"></param>
|
||||
/// <returns></returns>
|
||||
// POST: api/Parking_spaces_violation_total_table
|
||||
// To protect from overposting attacks, see https://go.microsoft.com/fwlink/?linkid=2123754
|
||||
[HttpPost]
|
||||
@ -109,7 +138,14 @@ namespace WebApi_data_value.Controllers
|
||||
|
||||
return CreatedAtAction("GetParking_spaces_violation_total_table", new { id = parking_spaces_violation_total_table.parking_spaces_violation_name }, parking_spaces_violation_total_table);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
// DELETE: api/Parking_spaces_violation_total_table/5
|
||||
[HttpDelete("{id}")]
|
||||
public async Task<IActionResult> DeleteParking_spaces_violation_total_table(string id)
|
||||
@ -129,7 +165,7 @@ namespace WebApi_data_value.Controllers
|
||||
|
||||
return NoContent();
|
||||
}
|
||||
|
||||
#endregion
|
||||
private bool Parking_spaces_violation_total_tableExists(string id)
|
||||
{
|
||||
return (_context.parking_spaces_violation_total_table?.Any(e => e.parking_spaces_violation_name == id)).GetValueOrDefault();
|
||||
|
@ -22,20 +22,34 @@ namespace WebApi_data_value.Controllers
|
||||
_context = context;
|
||||
}
|
||||
#region 抓取所有違規車輛
|
||||
/// <summary>
|
||||
/// 抓取所有違規車輛
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
// GET: api/Violation_car_table
|
||||
[HttpGet]
|
||||
public async Task<ActionResult<IEnumerable<Violation_car_table>>> Getviolation_car_table()
|
||||
{
|
||||
if (_context.violation_car_table == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
return await _context.violation_car_table.ToListAsync();
|
||||
var violation_car_table = await(from c in _context.violation_car_table
|
||||
orderby c.create_data_time descending
|
||||
select new Violation_car_table
|
||||
{
|
||||
license_plate_number = c.license_plate_number,
|
||||
create_data_time = c.create_data_time,
|
||||
violation_location_name=c.violation_location_name,
|
||||
|
||||
}).ToListAsync();
|
||||
return violation_car_table;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region 透過區域名稱抓取違規車輛
|
||||
/// <summary>
|
||||
/// 透過區域名稱抓取違規車輛
|
||||
/// </summary>
|
||||
/// <param name="id">違規區域</param>
|
||||
/// <returns></returns>
|
||||
// GET: api/Violation_car_table/5
|
||||
[HttpGet("violation_location_name-{id}")]
|
||||
public async Task<IEnumerable<Single_violation_car_table>> GetViolation_car_table(string id)
|
||||
@ -59,6 +73,12 @@ namespace WebApi_data_value.Controllers
|
||||
#endregion
|
||||
|
||||
#region 抓出指定違規車輛
|
||||
/// <summary>
|
||||
/// 抓出指定違規車輛
|
||||
/// </summary>
|
||||
/// <param name="id">違規區域</param>
|
||||
/// <param name="time">資料新增時間</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("location_nam-{id}-time-{time}")]
|
||||
public async Task<ActionResult<Violation_car_table>> violation_location_name(string id, DateTime time)
|
||||
{
|
||||
@ -83,6 +103,12 @@ namespace WebApi_data_value.Controllers
|
||||
|
||||
|
||||
#region 更新指定違規車輛
|
||||
/// <summary>
|
||||
/// 更新指定違規車輛
|
||||
/// </summary>
|
||||
/// <param name="id">區域</param>
|
||||
/// <param name="time">資料新增時間</param>
|
||||
/// <returns></returns>
|
||||
[HttpPut("location_nam-{id}-time-{time}")]
|
||||
public async Task<IActionResult> PutViolation_car_table(string id, DateTime time,Violation_car_table violation_car_table)
|
||||
{
|
||||
@ -100,41 +126,65 @@ namespace WebApi_data_value.Controllers
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
/*
|
||||
// PUT: api/Violation_car_table/5
|
||||
// To protect from overposting attacks, see https://go.microsoft.com/fwlink/?linkid=2123754
|
||||
[HttpPut("{id}")]
|
||||
public async Task<IActionResult> PutViolation_car_table(string id, Violation_car_table violation_car_table)
|
||||
#region 獲取時間內的資料
|
||||
/// <summary>
|
||||
/// 獲取時間內的車輛
|
||||
/// </summary>
|
||||
/// <param name="id">位置名稱</param>
|
||||
/// <param name="start_time">起始時間</param>
|
||||
/// <param name="end_time">結束時間</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("location_name_1_-{id}-start_time-{start_time}-end_time-{end_time}")]
|
||||
public async Task<IEnumerable<Single_violation_car_table>> GetYuntech_in_car_table_date(string id, DateTime start_time, DateTime end_time)
|
||||
{
|
||||
if (id != violation_car_table.violation_location_name)
|
||||
{
|
||||
return BadRequest();
|
||||
}
|
||||
|
||||
_context.Entry(violation_car_table).State = EntityState.Modified;
|
||||
var violation_car_table = await (from c in _context.violation_car_table
|
||||
where c.violation_location_name == id
|
||||
where c.create_data_time >= start_time
|
||||
where c.create_data_time <= end_time
|
||||
select new Single_violation_car_table
|
||||
{
|
||||
violation_location_name = c.violation_location_name,
|
||||
license_plate_number = c.license_plate_number,
|
||||
create_data_time = c.create_data_time,
|
||||
}).ToListAsync();
|
||||
|
||||
try
|
||||
{
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
catch (DbUpdateConcurrencyException)
|
||||
{
|
||||
if (!Violation_car_tableExists(id))
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
return NoContent();
|
||||
return violation_car_table;
|
||||
}
|
||||
*/
|
||||
#endregion
|
||||
|
||||
#region 透過車牌號碼搜尋所有資料
|
||||
/// <summary>
|
||||
/// 透過車牌號碼搜尋所有資料
|
||||
/// </summary>
|
||||
/// <param name="id">車牌號碼 ex:ABC4321</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("license_plate_number-{id}")]
|
||||
public async Task<IEnumerable<Single_violation_car_table>> Getlicense_plate_number(string id)
|
||||
{
|
||||
|
||||
var in_car_table = await (from c in _context.violation_car_table
|
||||
where c.license_plate_number == id
|
||||
orderby c.create_data_time descending
|
||||
select new Single_violation_car_table
|
||||
{
|
||||
violation_location_name = c.violation_location_name,
|
||||
license_plate_number = c.license_plate_number,
|
||||
create_data_time = c.create_data_time,
|
||||
}).ToListAsync();
|
||||
|
||||
|
||||
return in_car_table;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 新增違規車輛
|
||||
/// <summary>
|
||||
/// 新增違規車輛
|
||||
/// </summary>
|
||||
/// <param name="violation_car_table"></param>
|
||||
/// <returns></returns>
|
||||
// POST: api/Violation_car_table
|
||||
// To protect from overposting attacks, see https://go.microsoft.com/fwlink/?linkid=2123754
|
||||
[HttpPost]
|
||||
@ -167,6 +217,12 @@ namespace WebApi_data_value.Controllers
|
||||
#endregion
|
||||
|
||||
#region 刪除違規車輛
|
||||
/// <summary>
|
||||
/// 刪除違規車輛
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="time"></param>
|
||||
/// <returns></returns>
|
||||
// DELETE: api/Violation_car_table/5
|
||||
[HttpDelete("location_name-{id}-time-{time}")]
|
||||
public async Task<IActionResult> DeleteViolation_car_table(string id, DateTime time)
|
||||
|
@ -11,6 +11,7 @@ using WebApi_data_value.ViewModel;
|
||||
|
||||
namespace WebApi_data_value.Controllers
|
||||
{
|
||||
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class Yuntech_in_car_tableController : ControllerBase
|
||||
@ -21,7 +22,10 @@ namespace WebApi_data_value.Controllers
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
#region 獲取進入雲科的所有資料
|
||||
/// <summary>
|
||||
/// 獲取進入雲科的所有資料
|
||||
/// </summary>
|
||||
// GET: api/Yuntech_in_car_table
|
||||
[HttpGet]
|
||||
public async Task<ActionResult<IEnumerable<Yuntech_in_car_table>>> Getyuntech_in_car_table()
|
||||
@ -40,9 +44,14 @@ namespace WebApi_data_value.Controllers
|
||||
|
||||
return in_car_table;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 獲取進入的單獨地區的所有資料
|
||||
/// <summary>
|
||||
/// 獲取進入的單獨地區的所有資料
|
||||
/// </summary>
|
||||
/// <param name="id"> 哪個門口</param>
|
||||
/// <returns></returns>
|
||||
// GET: api/Yuntech_in_car_table/5
|
||||
[HttpGet("location-{id}")]
|
||||
public async Task<IEnumerable<Yuntech_in_car_table>> GetYuntech_in_car_table(string id)
|
||||
@ -56,23 +65,90 @@ namespace WebApi_data_value.Controllers
|
||||
in_time = c.in_time,
|
||||
out_time = c.out_time,
|
||||
location = c.location,
|
||||
}
|
||||
).ToListAsync();
|
||||
}).ToListAsync();
|
||||
|
||||
|
||||
return in_car_table;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 獲取進入的單獨地區的所有資料
|
||||
#region 獲取時間內的車輛
|
||||
/// <summary>
|
||||
/// 獲取時間內的車輛
|
||||
/// </summary>
|
||||
/// <param name="id">位置名稱</param>
|
||||
/// <param name="start_time">起始時間</param>
|
||||
/// <param name="end_time">結束時間</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("location_name_1_-{id}-start_time-{start_time}-end_time-{end_time}")]
|
||||
public async Task<IEnumerable<Yuntech_in_car_table>> GetYuntech_in_car_table_date(string id,DateTime start_time, DateTime end_time)
|
||||
{
|
||||
|
||||
var in_car_table = await (from c in _context.yuntech_in_car_table
|
||||
where c.location == id
|
||||
where c.in_time >= start_time
|
||||
where c.in_time <= end_time
|
||||
select new Yuntech_in_car_table
|
||||
{
|
||||
license_plate_number = c.license_plate_number,
|
||||
in_time = c.in_time,
|
||||
out_time = c.out_time,
|
||||
location = c.location,
|
||||
}).ToListAsync();
|
||||
|
||||
|
||||
return in_car_table;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 透過車牌號碼搜尋所有資料
|
||||
/// <summary>
|
||||
/// 透過車牌號碼搜尋所有資料
|
||||
/// </summary>
|
||||
/// <param name="id">車牌號碼 ex:ABC4321</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("license_plate_number-{id}")]
|
||||
public async Task<IEnumerable<Yuntech_in_car_table>> Getlicense_plate_number(string id)
|
||||
{
|
||||
|
||||
var in_car_table = await (from c in _context.yuntech_in_car_table
|
||||
where c.license_plate_number == id
|
||||
orderby c.in_time descending
|
||||
select new Yuntech_in_car_table
|
||||
{
|
||||
license_plate_number = c.license_plate_number,
|
||||
in_time = c.in_time,
|
||||
out_time = c.out_time,
|
||||
location = c.location,
|
||||
}).ToListAsync();
|
||||
|
||||
|
||||
return in_car_table;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 獲取進入的單獨地區的單筆資料
|
||||
/// <summary>
|
||||
/// 獲取進入的單獨地區的單筆資料
|
||||
/// </summary>
|
||||
/// <param name="id">地區</param>
|
||||
/// <param name="time">進入時間 ex:2024-02-05T12:21:48.395Z</param>
|
||||
/// <returns></returns>
|
||||
// GET: api/Yuntech_in_car_table/5
|
||||
[HttpGet("location-{id}-time-{time}")]
|
||||
[HttpGet("location_name-{id}-time-{time}")]
|
||||
public async Task<ActionResult<Yuntech_in_car_table>> One_data(string id, DateTime time)
|
||||
{
|
||||
var in_car_table = await (from c in _context.yuntech_in_car_table
|
||||
where c.location == id
|
||||
where c.in_time == time
|
||||
select c).FirstAsync();
|
||||
select new Yuntech_in_car_table
|
||||
{
|
||||
license_plate_number= c.license_plate_number,
|
||||
in_time = c.in_time,
|
||||
out_time = c.out_time,
|
||||
car_img = c.car_img,
|
||||
location = c.location,
|
||||
}).FirstAsync();
|
||||
|
||||
|
||||
return in_car_table;
|
||||
@ -81,7 +157,12 @@ namespace WebApi_data_value.Controllers
|
||||
|
||||
|
||||
|
||||
|
||||
#region 新增資料
|
||||
/// <summary>
|
||||
/// 新增進入雲科的車輛資料
|
||||
/// </summary>
|
||||
/// <param name="yuntech_in_car_table"></param>
|
||||
/// <returns></returns>
|
||||
// POST: api/Yuntech_in_car_table
|
||||
// To protect from overposting attacks, see https://go.microsoft.com/fwlink/?linkid=2123754
|
||||
[HttpPost]
|
||||
@ -112,8 +193,8 @@ namespace WebApi_data_value.Controllers
|
||||
|
||||
return CreatedAtAction("GetYuntech_in_car_table", new { id = yuntech_in_car_table.in_time }, yuntech_in_car_table);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
private bool Yuntech_in_car_tableExists(DateTime? id)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user