59 lines
1.7 KiB
C#
59 lines
1.7 KiB
C#
using System;
|
|
using System.Net;
|
|
using System.Net.Http;
|
|
using System.Web.Http;
|
|
using Interfaces;
|
|
|
|
namespace WindowsDataCenter
|
|
{
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
[RoutePrefix("api/swipedata")]
|
|
public class SwipeDataController : ApiController
|
|
{
|
|
private readonly IRepository _repo;
|
|
private readonly ILogger _logger;
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="repo"></param>
|
|
public SwipeDataController(IRepository repo, ILogger logger)
|
|
{
|
|
if(repo == null) throw new ArgumentNullException(nameof(repo));
|
|
_repo = repo;
|
|
if(logger == null) throw new ArgumentNullException(nameof(logger));
|
|
_logger = logger;
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="cData"></param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
[Route("")]
|
|
public IHttpActionResult PostData([FromBody] CardData cData)
|
|
{
|
|
int logId;
|
|
_repo.LogEventTime(new Identifier {UniqueId = cData.CardUId}, out logId);
|
|
_logger.Trace("Received new \"Swipe Event\" for UId: {0} at {1}", cData.CardUId, DateTime.UtcNow);
|
|
return
|
|
ResponseMessage(new HttpResponseMessage(HttpStatusCode.OK)
|
|
{
|
|
Content = new StringContent(logId.ToString())
|
|
});
|
|
}
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="log"></param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
[Route("manual")]
|
|
public IHttpActionResult ManuallyPostData([FromBody] ManualLog log)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
}
|
|
} |