Refactor code to simplify methods.
This commit is contained in:
parent
7110e3e2fe
commit
b0b1fd4576
@ -67,26 +67,15 @@ namespace SQLiteRepository
|
||||
foreach (var user in users)
|
||||
{
|
||||
var userObj = ChangeToUserObject(user);
|
||||
var cards = _connection.Query<CardUniqueId>(
|
||||
SQLiteProcedures.GET_CARDS_BY_USER_ID,
|
||||
user.Id);
|
||||
|
||||
foreach (var card in cards)
|
||||
{
|
||||
userObj.AssociatedIdentifiers.Add(new Identifier()
|
||||
{
|
||||
UniqueId = card.CardUId,
|
||||
IsAssociatedToUser = true,
|
||||
Id = card.Id
|
||||
});
|
||||
}
|
||||
userObj.AssociatedIdentifiers = GetAssociatedIdentifiers(user.Id);
|
||||
userObj.State = GetUserState(GetLogDirection(user.Id));
|
||||
|
||||
userObj.LastEventDateTime = GetLastLogDateTime(GetLastTimeLog(user.Id));
|
||||
ret.Users.Add(userObj);
|
||||
}
|
||||
if (pageNumber == -1 && pageSize == -1)
|
||||
{
|
||||
ret.PageSize = 1; //TODO: switch to ret.UserCount
|
||||
ret.PageSize = 10;
|
||||
ret.PageNumber = 1;
|
||||
}
|
||||
else
|
||||
@ -106,6 +95,7 @@ namespace SQLiteRepository
|
||||
}
|
||||
return DateTime.MinValue;
|
||||
}
|
||||
|
||||
private bool GetUserState(LogDirectionDb logDirection)
|
||||
{
|
||||
switch (logDirection)
|
||||
@ -150,6 +140,7 @@ namespace SQLiteRepository
|
||||
Id = card.Id
|
||||
});
|
||||
}
|
||||
userObj.State = GetUserState(GetLogDirection(user.Id));
|
||||
ret.Users.Add(userObj);
|
||||
}
|
||||
//TODO: figure out paging here. - should there be any?
|
||||
@ -194,7 +185,7 @@ namespace SQLiteRepository
|
||||
|
||||
return ret;
|
||||
}
|
||||
//TODO: refac this as it duplicates a lot of code.
|
||||
|
||||
public TimeLogList GetTimeLogs(int userId)
|
||||
{
|
||||
return GetTimeLogs(userId, DateTime.UtcNow);
|
||||
@ -548,6 +539,25 @@ namespace SQLiteRepository
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private List<Identifier> GetAssociatedIdentifiers(int userId)
|
||||
{
|
||||
var cards = _connection.Query<CardUniqueId>(
|
||||
SQLiteProcedures.GET_CARDS_BY_USER_ID,
|
||||
userId);
|
||||
var ret = new List<Identifier>();
|
||||
foreach (var card in cards)
|
||||
{
|
||||
ret.Add(new Identifier()
|
||||
{
|
||||
UniqueId = card.CardUId,
|
||||
IsAssociatedToUser = true,
|
||||
Id = card.Id
|
||||
});
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the calendar week of the year according to the ISO8601 standard (starts monday).
|
||||
/// </summary>
|
||||
|
||||
@ -76,7 +76,9 @@
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
<None Include="App.config">
|
||||
<SubType>Designer</SubType>
|
||||
</None>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user