changed api method to use the return type of IRepository.LogEventTime method and return the Id and Direction from the endpoint.

#17
This commit is contained in:
chris.watts90@outlook.com 2017-04-16 19:41:31 +01:00
parent c92ed064fc
commit 3446dda710

View File

@ -14,10 +14,12 @@ namespace WindowsDataCenter
{ {
private readonly IRepository _repo; private readonly IRepository _repo;
private readonly ILogger _logger; private readonly ILogger _logger;
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
/// <param name="repo"></param> /// <param name="repo"></param>
/// <param name="logger"></param>
public SwipeDataController(IRepository repo, ILogger logger) public SwipeDataController(IRepository repo, ILogger logger)
{ {
if(repo == null) throw new ArgumentNullException(nameof(repo)); if(repo == null) throw new ArgumentNullException(nameof(repo));
@ -36,13 +38,10 @@ namespace WindowsDataCenter
public IHttpActionResult PostData([FromBody] CardData cData) public IHttpActionResult PostData([FromBody] CardData cData)
{ {
int logId; int logId;
_repo.LogEventTime(new Identifier {UniqueId = cData.CardUId}, out logId); var resp = _repo.LogEventTime(new Identifier {UniqueId = cData.CardUId}, out logId);
_logger.Trace("Received new \"Swipe Event\" for UId: {0} at {1}", cData.CardUId, DateTime.UtcNow); _logger.Trace("Received new \"Swipe Event\" for UId: {0} at {1}, direction is : {2}", cData.CardUId,
return DateTime.UtcNow, resp.Direction);
ResponseMessage(new HttpResponseMessage(HttpStatusCode.OK) return Ok(new {Id = logId, resp.Direction});
{
Content = new StringContent(logId.ToString())
});
} }
} }
} }