From 3446dda71073c805c8d27814335169ebc4862c00 Mon Sep 17 00:00:00 2001 From: "chris.watts90@outlook.com" Date: Sun, 16 Apr 2017 19:41:31 +0100 Subject: [PATCH] changed api method to use the return type of IRepository.LogEventTime method and return the Id and Direction from the endpoint. #17 --- .../Controllers/SwipeDataController.cs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Controllers/SwipeDataController.cs b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Controllers/SwipeDataController.cs index a1b8a9d..ed31a9f 100644 --- a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Controllers/SwipeDataController.cs +++ b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Controllers/SwipeDataController.cs @@ -14,10 +14,12 @@ namespace WindowsDataCenter { private readonly IRepository _repo; private readonly ILogger _logger; + /// /// /// /// + /// public SwipeDataController(IRepository repo, ILogger logger) { if(repo == null) throw new ArgumentNullException(nameof(repo)); @@ -36,13 +38,10 @@ namespace WindowsDataCenter 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()) - }); + var resp = _repo.LogEventTime(new Identifier {UniqueId = cData.CardUId}, out logId); + _logger.Trace("Received new \"Swipe Event\" for UId: {0} at {1}, direction is : {2}", cData.CardUId, + DateTime.UtcNow, resp.Direction); + return Ok(new {Id = logId, resp.Direction}); } } } \ No newline at end of file