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..
61 lines
1.8 KiB
C#
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")
|
|
});
|
|
}
|
|
}
|
|
} |