FlexitimeTracker/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Controllers/SwipeDataController.cs

37 lines
1.0 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 readonly IRepository _repo;
public SwipeDataController(IRepository repo)
{
if(repo == null) throw new ArgumentNullException();
_repo = repo;
}
[HttpPost]
[Route("")]
public IHttpActionResult PostData([FromBody] CardData cData)
{
int logId;
_repo.LogEventTime(new Identifier {UniqueId = cData.CardUId}, out logId);
return
ResponseMessage(new HttpResponseMessage(HttpStatusCode.OK)
{
Content = new StringContent(logId.ToString())
});
}
//need another method here for posting.
//public IHttpActionResult ManuallyPostData([FromBody] ManualLog log){
//
//}
}
}