diff --git a/DataCenter_Windows/WindowsDataCenter/Interfaces/IRepository.cs b/DataCenter_Windows/WindowsDataCenter/Interfaces/IRepository.cs index 30f8141..e5e4f59 100644 --- a/DataCenter_Windows/WindowsDataCenter/Interfaces/IRepository.cs +++ b/DataCenter_Windows/WindowsDataCenter/Interfaces/IRepository.cs @@ -66,6 +66,10 @@ namespace Interfaces /// with nested list /// IdentifierList GetUnassignedIdentifierList(); + /// + /// Remove all unassigned identifiers from the system. + /// + void ClearUnassignedIdentifiers(); /// /// Update a user in the system with the new values. diff --git a/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/SQLiteProcedures.cs b/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/SQLiteProcedures.cs index 9b810f8..bcded4e 100644 --- a/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/SQLiteProcedures.cs +++ b/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/SQLiteProcedures.cs @@ -63,6 +63,9 @@ namespace SQLiteRepository public const string GET_UNASSIGNED_CARD_LIST = "select * from " + nameof(CardUniqueId) + " where " + nameof(CardUniqueId.UserId_FK) + "=?"; + public const string CLEAR_UNASSIGNED_CARDS = + "delete from " + nameof(CardUniqueId) + " where " + nameof(CardUniqueId.UserId_FK) + "=?"; + public const string UPDATE_CARD_USER_ID = "update " + nameof(CardUniqueId) + " set " + nameof(CardUniqueId.UserId_FK) + "=? where " + nameof(CardUniqueId.Id) + "=?"; diff --git a/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/SQLiteRepository.cs b/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/SQLiteRepository.cs index 01e3a60..c867d5d 100644 --- a/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/SQLiteRepository.cs +++ b/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/SQLiteRepository.cs @@ -309,6 +309,13 @@ namespace SQLiteRepository return ret; } + public void ClearUnassignedIdentifiers() + { + _connection.Execute( + SQLiteProcedures.CLEAR_UNASSIGNED_CARDS, + Constants.UNASSIGNED_CARD_USER_ID); + } + //TODO: Check time logs table on update to ensure associated cards/unique identifiers are removed/added as appropriate. public OperationResponse UpdateUser(User user, out int userIdResult) { diff --git a/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/SQLiteRepository.csproj b/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/SQLiteRepository.csproj index eece48e..46517fc 100644 --- a/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/SQLiteRepository.csproj +++ b/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/SQLiteRepository.csproj @@ -77,7 +77,6 @@ - @@ -107,9 +106,6 @@ - - - diff --git a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Controllers/CardsController.cs b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Controllers/CardsController.cs index 8908259..ee9d5b5 100644 --- a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Controllers/CardsController.cs +++ b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Controllers/CardsController.cs @@ -27,5 +27,15 @@ namespace WindowsDataCenter _logger.Trace("Call to GetUnassignedCards, returning {0} items", unassignedCards.data.Count); return Ok(unassignedCards); } + + [HttpDelete] + [Route("unassigned")] + [CacheControl(MaxAge = 0)] + public IHttpActionResult ClearUnassignedCards() + { + _repo.ClearUnassignedIdentifiers(); + _logger.Trace("Call to ClearUnassignedCards, removed all identifiers."); + return Ok(); + } } } \ No newline at end of file diff --git a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/www/Admin.html b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/www/Admin.html index c4fcdb6..b6667d0 100644 --- a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/www/Admin.html +++ b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/www/Admin.html @@ -77,7 +77,33 @@ + + + Unassigned Cards + + + + + + + + + + Card Unique Id + Last Used Date + + + + + + + + + + + + - +