public AuthenticationLogDto(AuthenticationLog log) { Id = log.Id; Type = (TypeKey)Enum.Parse(typeof(TypeKey), log.GetType().ShortDisplayName()); Time = log.Time; Sim = log.Sim; SimAndDevice = log switch { SimAndDeviceAuthenticationSuccessLog a => a.SimAndDevice, SimAndDeviceAuthenticationFailureLog _ => null, MultiFactorAuthenticationSuccessLog _ => null, MultiFactorAuthenticationFailureLog a => a.SimAndDevice, DeauthenticationLog _ => null, _ => null }; MultiFactor = log switch { SimAndDeviceAuthenticationSuccessLog _ => null, SimAndDeviceAuthenticationFailureLog _ => null, MultiFactorAuthenticationSuccessLog a => a.MultiFactor, MultiFactorAuthenticationFailureLog _ => null, DeauthenticationLog a => a.MultiFactor, _ => null }; } } }
private DeauthenticationLog CreateDeauthenticationLog(MultiFactorAuthenticated multiFactorAuthenticated) { var deauthenticationLog = new DeauthenticationLog { MultiFactor = multiFactorAuthenticated.MultiFactor, Time = DateTime.Now, Sim = multiFactorAuthenticated.MultiFactor.SimAndDevice.Sim }; return(deauthenticationLog); }