FlexitimeTracker/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/SwipeDataController.cs
chris.watts90@outlook.com 1e8d56ab82 csproj update to reference Interfaces and SQLiteRepository implementation.
Complete IRepository migration into the ApiControllers.
remove any nuget packages from the packages.config which refer to sqlite and entity framework.
missing csproj update for SQLiteRepository project. Sorry..
2017-01-31 22:09:40 +00:00

61 lines
1.8 KiB
C#

using System;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using Interfaces;
namespace WindowsDataCenter
{
[RoutePrefix("api/swipedata")]
public class SwipeDataController : ApiController
{
//private SQLiteConnection _connection;
private readonly IRepository _repo;
public SwipeDataController(IRepository repo)
{
if(repo == null) throw new ArgumentNullException();
_repo = repo;
//_connection = conn;
}
[HttpPost]
[Route("")]
public IHttpActionResult PostData([FromBody] CardData cData)
{
//var cardIdQuery = _connection.Query<CardUniqueId>(
// "select * from CardUniqueIds where CardUId = ?",
// cData.CardUId);
//var userId = 0;
//if (!cardIdQuery.Any())
//{
// //new card, create it!
// userId = _connection.Insert(new CardUniqueId()
// {
// UserId_FK = -1,
// CardUId = cData.CardUId
// });
//}
//else
//{
// //TODO: handle when more than one comes back. should NEVER happen but....
// userId = cardIdQuery.First().UserId_FK;
//}
//var timeLog = new TimeLog
//{
// SwipeEventDateTime = DateTime.UtcNow,
// UserId_FK = userId
//};
//var tLogId = _connection.Insert(timeLog);
//TODO: TEST
_repo.LogEventTime(new Identifier {UniqueId = cData.CardUId});
return
ResponseMessage(new HttpResponseMessage(HttpStatusCode.OK)
{
Content = new StringContent("TODO: return ID")
});
}
}
}