feat(models): add ConnectionTestOutcome for device connectivity
Online, Auth Failed, API Error, Timeout, Offline, and dashboard mapping helpers.main
parent
82dfa54e39
commit
df0d5a77ee
|
|
@ -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;
|
||||
}
|
||||
Loading…
Reference in New Issue