added stub/comment for manual swipe data log submission.

returned user id in user edit
started working on the direction/logtime method
This commit is contained in:
Chris.Watts90@outlook.com 2017-02-08 16:51:23 +00:00
parent 56fa9c60b0
commit 54d11ddf9d
3 changed files with 38 additions and 7 deletions

View File

@ -254,16 +254,38 @@ namespace SQLiteRepository
} }
else else
{ {
//TODO: handle when more than one comes back. should NEVER happen but.... //TODO: log when more than one comes back. should NEVER happen but....
ident = cardIdQuery.First(); ident = cardIdQuery.First();
} }
//TODO: change log direction to an ENUM
//TODO: Handle In/Out Flag.. //TODO: Handle In/Out Flag..
var logDirection = false;
//get the last flag //get the last flag
if (ident.UserId_FK != -1)
{
var lastEntry = _connection.Query<TimeLog>(
SQLiteProcedures.GET_LAST_TIMELOG_DIRECTION,
ident.UserId_FK);
if (lastEntry.Any())
{
var lastLog = lastEntry.First();
// See if the datetime retrieved is yesterday. If yesterday, logDirection = true (in)
if (IsLogDateTimeYesterdayOrOlder(lastLog.SwipeEventDateTime.DateTime))
{
logDirection = true;
}
else
{
logDirection = !lastLog.InOut;
}
}
}
else
{
logDirection = false; //TODO: need an "unknown" state..
}
//SQLiteProcedures.GET_LAST_TIMELOG_DIRECTION //SQLiteProcedures.GET_LAST_TIMELOG_DIRECTION
//then invert it, and store it.. //then invert it, and store it..
var logDirection = false;
//TODO: See if the datetime retrieved is yesterday. If yesterday, logDirection = true (in)
//TODO: Handle When the identifier is assigned to a user (identifier has -1) //TODO: Handle When the identifier is assigned to a user (identifier has -1)
//when identifier not assigned to user, just store it anyway and carry on, can update later. //when identifier not assigned to user, just store it anyway and carry on, can update later.
@ -280,6 +302,11 @@ namespace SQLiteRepository
return OperationResponse.SUCCESS; return OperationResponse.SUCCESS;
} }
private bool IsLogDateTimeYesterdayOrOlder(DateTime dt)
{
return dt.Date.CompareTo(DateTime.Today.Date) < 0;
}
private User ChangeToUserObject(UserIdentity user) private User ChangeToUserObject(UserIdentity user)
{ {
return new User return new User

View File

@ -54,5 +54,10 @@ namespace WindowsDataCenter
Content = new StringContent("TODO: return ID") Content = new StringContent("TODO: return ID")
}); });
} }
//need another method here for posting.
//public IHttpActionResult ManuallyPostData([FromBody] ManualLog log){
//
//}
} }
} }

View File

@ -60,8 +60,7 @@ namespace WindowsDataCenter
{ {
int userId; int userId;
_repo.UpdateUser(user, out userId); _repo.UpdateUser(user, out userId);
//TODO: MUST HAVE - return user id! var resp = Request.CreateResponse(HttpStatusCode.OK, userId);
var resp = Request.CreateResponse(HttpStatusCode.OK, "TODO:return UserID");
return ResponseMessage(resp); return ResponseMessage(resp);
//ResponseMessage(new HttpResponseMessage(HttpStatusCode.Created) //ResponseMessage(new HttpResponseMessage(HttpStatusCode.Created)
//{ //{