public ConnectionViewModel Assemble(ConnectionRecord connectionRecord) { if (connectionRecord == null) { return(null); } ConnectionViewModel connection = _scope.Resolve <ConnectionViewModel>(new NamedParameter("record", connectionRecord)); if (string.IsNullOrWhiteSpace(connection.ConnectionName)) { connection.ConnectionName = "Agent Médiateur"; } connection.ConnectionSubtitle = ConnectionStateTranslator.Translate(connectionRecord.State); DateTime datetime = DateTime.Now; if (connectionRecord.CreatedAtUtc.HasValue) { datetime = connectionRecord.CreatedAtUtc.Value.ToLocalTime(); connection.DateTime = datetime; } return(connection); }
private void AddOrUpdateConnection(ConnectionRecord connectionRecord) { foreach (ConnectionViewModel connection in Connections) { if (connectionRecord.Id == connection.Id) { connection.ConnectionSubtitle = ConnectionStateTranslator.Translate(connectionRecord.State); return; } } var con = _scope.Resolve <ConnectionViewModel>(new NamedParameter("record", connectionRecord)); if (string.IsNullOrWhiteSpace(con.ConnectionName)) { con.ConnectionName = "Agent Médiateur"; } con.ConnectionSubtitle = ConnectionStateTranslator.Translate(connectionRecord.State); DateTime datetime = DateTime.Now; if (connectionRecord.CreatedAtUtc.HasValue) { datetime = connectionRecord.CreatedAtUtc.Value.ToLocalTime(); con.DateTime = datetime; } Connections.Insert(0, con); }
/// <summary> /// Convert <see cref="ConnectionState"/> to translated <see cref="string"/>. /// </summary> /// <param name="value">Object from type <see cref="ConnectionState"/>.</param> /// <param name="targetType"></param> /// <param name="parameter"></param> /// <param name="culture"></param> /// <returns>Translated <see cref="ConnectionState"/>.</returns> public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (!(value is ConnectionState connectionState)) { return("-/-"); } return(ConnectionStateTranslator.GetInstance().Translate(connectionState)); }