feat(models): add ConnectionTestOutcome for device connectivity

Online, Auth Failed, API Error, Timeout, Offline, and dashboard mapping helpers.
main
SYED MUSTUFA AHMED NAQVI 2026-08-27 09:39:55 +05:00
parent 82dfa54e39
commit df0d5a77ee
1 changed files with 31 additions and 0 deletions

View File

@ -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;
}