diff --git a/WebApi_data_value/Controllers/Yuntech_in_car_tableController.cs b/WebApi_data_value/Controllers/Yuntech_in_car_tableController.cs
index b8633ed..bcf4514 100644
--- a/WebApi_data_value/Controllers/Yuntech_in_car_tableController.cs
+++ b/WebApi_data_value/Controllers/Yuntech_in_car_tableController.cs
@@ -257,11 +257,12 @@ namespace Parking_space_WebAPI.Controllers
{
return Problem("Entity set 'SqlContext.yuntech_in_car_table' is null.");
}
- _context.yuntech_in_car_table.Add(yuntech_in_car_table);
+
try
{
yuntech_in_car_table.in_time = DateTime.Now;
yuntech_in_car_table.out_time = null;
+ _context.yuntech_in_car_table.Add(yuntech_in_car_table);
await _context.SaveChangesAsync();
}
catch (DbUpdateException)
@@ -281,6 +282,75 @@ namespace Parking_space_WebAPI.Controllers
#endregion
+ #region 新增出去資料
+ ///
+ /// 新增出去雲科的車輛資料
+ ///
+ ///
+ ///
+ // POST: api/Yuntech_in_car_table
+ // To protect from overposting attacks, see https://go.microsoft.com/fwlink/?linkid=2123754
+ [HttpPost("out_car")]
+ public async Task> PostYuntech_out_car_table(Yuntech_in_car_table yuntech_out_car_table)
+ {
+ if (_context.yuntech_in_car_table == null)
+ {
+ return Problem("Entity set 'SqlContext.yuntech_in_car_table' is null.");
+ }
+ var license_plate_number = yuntech_out_car_table.license_plate_number;
+ var out_car_img = yuntech_out_car_table.out_car_img;
+ var in_car_data = await(from c in _context.yuntech_in_car_table
+ where c.license_plate_number == license_plate_number
+ where c.out_time ==null
+ orderby c.in_time descending
+ select c).FirstOrDefaultAsync();
+ if (in_car_data != null)
+ {
+ // 处理找到记录的情况
+ _context.yuntech_in_car_table.Remove(in_car_data);
+ await _context.SaveChangesAsync();
+ in_car_data.out_time = DateTime.Now;
+ in_car_data.out_car_img = out_car_img;
+ _context.yuntech_in_car_table.Add(in_car_data);
+ await _context.SaveChangesAsync();
+ }
+ else
+ {
+ // 处理未找到记录的情况
+ await _context.SaveChangesAsync();
+ }
+
+
+
+
+ return Ok();
+ }
+ #endregion
+
+ #region 刪除資料
+ ///
+ /// 刪除指定資料
+ ///
+ /// 車牌號碼
+ /// 資料新增時間
+ ///
+ [HttpDelete("license_plate_number-{license_plate_number}-time-{time}")]
+ public async Task Deletein_car_table(string license_plate_number, DateTime time)
+ {
+ var in_car_table = await (from c in _context.yuntech_in_car_table
+ where c.license_plate_number == license_plate_number
+ where c.in_time == time
+
+ select c).FirstAsync();
+
+
+ _context.yuntech_in_car_table.Remove(in_car_table);
+ await _context.SaveChangesAsync();
+
+ return NoContent();
+ }
+ #endregion
+
private bool Yuntech_in_car_tableExists(DateTime? id)
{
return (_context.yuntech_in_car_table?.Any(e => e.in_time == id)).GetValueOrDefault();
diff --git a/WebApi_data_value/Models/Yuntech_in_car_table.cs b/WebApi_data_value/Models/Yuntech_in_car_table.cs
index 5f5aa6a..ef87a74 100644
--- a/WebApi_data_value/Models/Yuntech_in_car_table.cs
+++ b/WebApi_data_value/Models/Yuntech_in_car_table.cs
@@ -4,6 +4,7 @@
{
public string? license_plate_number { get; set; }
public string? car_img { get; set; }
+ public string? out_car_img { get; set; }
public string? location { get; set; }
public DateTime? in_time { get; set; }
public DateTime? out_time { get; set; }