54 lines
1.7 KiB
C#
54 lines
1.7 KiB
C#
// =============================================================================
|
|
// SAMPLE API POST ENDPOINT (for reference / testing)
|
|
// =============================================================================
|
|
// This file is NOT compiled; it shows how a server could accept the sync POST
|
|
// from UtopiaCanteenSystem. Add something like this to your UIND sync API.
|
|
//
|
|
// Expected request from UtopiaCanteenSystem:
|
|
// POST {SyncApiEndpoint} (e.g. https://api.example.com/uind/sync)
|
|
// Content-Type: application/json
|
|
// Body: array of scan records, e.g.:
|
|
// [
|
|
// { "Id": 1, "CardId": "RFID123", "ScanTime": "2025-01-30T10:00:00Z", "IsSynced": false },
|
|
// { "Id": 2, "CardId": "RFID456", "ScanTime": "2025-01-30T10:05:00Z", "IsSynced": false }
|
|
// ]
|
|
//
|
|
// Response: 2xx success → client will mark those records as IsSynced = true.
|
|
// =============================================================================
|
|
|
|
#if false // Sample ASP.NET Core controller (paste into your API project)
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace YourApi.Controllers;
|
|
|
|
[ApiController]
|
|
[Route("uind/sync")]
|
|
public class UindSyncController : ControllerBase
|
|
{
|
|
[HttpPost]
|
|
public IActionResult Sync([FromBody] List<SyncRecordDto> records)
|
|
{
|
|
if (records == null || records.Count == 0)
|
|
return Ok();
|
|
|
|
// Persist or process records (e.g. save to your database)
|
|
foreach (var r in records)
|
|
{
|
|
// Save r.Id, r.CardId, r.ScanTime, etc.
|
|
}
|
|
|
|
return Ok();
|
|
}
|
|
}
|
|
|
|
public class SyncRecordDto
|
|
{
|
|
public int Id { get; set; }
|
|
public string CardId { get; set; } = string.Empty;
|
|
public DateTime ScanTime { get; set; }
|
|
public bool IsSynced { get; set; }
|
|
}
|
|
|
|
#endif
|