From df0d5a77ee96f7a88bbb94411c3b8994d5d4f606 Mon Sep 17 00:00:00 2001 From: Syed Mustafa Ahmed Naqvi Date: Thu, 27 Aug 2026 09:39:55 +0500 Subject: [PATCH] feat(models): add ConnectionTestOutcome for device connectivity Online, Auth Failed, API Error, Timeout, Offline, and dashboard mapping helpers. --- .../Models/ConnectionTestOutcome.cs | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/HikvisionAttendanceManager.App/Models/ConnectionTestOutcome.cs diff --git a/src/HikvisionAttendanceManager.App/Models/ConnectionTestOutcome.cs b/src/HikvisionAttendanceManager.App/Models/ConnectionTestOutcome.cs new file mode 100644 index 0000000..f82b192 --- /dev/null +++ b/src/HikvisionAttendanceManager.App/Models/ConnectionTestOutcome.cs @@ -0,0 +1,31 @@ +namespace HikvisionAttendanceManager.App.Models; + +public enum ConnectionTestOutcome +{ + Online, + AuthenticationFailed, + ApiResponseError, + Timeout, + Offline, + CredentialsMissing +} + +public static class ConnectionTestOutcomeExtensions +{ + public static string ToDashboardStatus(this ConnectionTestOutcome outcome) => outcome switch + { + ConnectionTestOutcome.Online => "Online", + ConnectionTestOutcome.ApiResponseError => "API Error", + ConnectionTestOutcome.AuthenticationFailed => "Authentication Failed", + ConnectionTestOutcome.Timeout => "Offline", + ConnectionTestOutcome.Offline => "Offline", + ConnectionTestOutcome.CredentialsMissing => "Not Tested", + _ => "Not Tested" + }; + + public static bool CountsAsOnline(this ConnectionTestOutcome outcome) => + outcome is ConnectionTestOutcome.Online or ConnectionTestOutcome.ApiResponseError; + + public static bool CountsAsOffline(this ConnectionTestOutcome outcome) => + outcome is ConnectionTestOutcome.Timeout or ConnectionTestOutcome.Offline; +}