Refactor Api-Client
Add Exceptionhandler, AlertService JSON-Converter AppSettings via DI Reformat Code
This commit is contained in:
@@ -2,20 +2,21 @@
|
||||
|
||||
/// Gib true zurück, wenn die Collection Werte enthält
|
||||
namespace Jugenddienst_Stunden.Converter {
|
||||
internal class CollectionVisibilityConverter : IValueConverter {
|
||||
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) {
|
||||
if (value is IEnumerable<object> collection) {
|
||||
if ((string)parameter == "Invert")
|
||||
return !collection.Any();
|
||||
return collection.Any();
|
||||
}
|
||||
if ((string)parameter == "Invert")
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
internal class CollectionVisibilityConverter : IValueConverter {
|
||||
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) {
|
||||
if (value is IEnumerable<object> collection) {
|
||||
if ((string)parameter == "Invert")
|
||||
return !collection.Any();
|
||||
return collection.Any();
|
||||
}
|
||||
|
||||
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((string)parameter == "Invert")
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
using System.Globalization;
|
||||
|
||||
namespace Jugenddienst_Stunden.Converter;
|
||||
|
||||
/// <summary>
|
||||
/// Falls ein int als bool dargestellt werden soll
|
||||
/// </summary>
|
||||
public class IntBoolConverter : IValueConverter {
|
||||
|
||||
/// <summary>
|
||||
/// Konvertiert einen int in einen bool
|
||||
/// </summary>
|
||||
@@ -18,6 +18,7 @@ public class IntBoolConverter : IValueConverter {
|
||||
if (value is int) {
|
||||
return (int)value != 0;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -33,6 +34,7 @@ public class IntBoolConverter : IValueConverter {
|
||||
if (value is bool) {
|
||||
return (bool)value ? 1 : 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,36 +1,37 @@
|
||||
using System.Globalization;
|
||||
|
||||
namespace Jugenddienst_Stunden.Converter;
|
||||
|
||||
internal class SecondsTimeConverter : IValueConverter {
|
||||
private int seconds;
|
||||
|
||||
private int seconds;
|
||||
/// <summary>
|
||||
/// Konvertiert eine Sekundenangabe nach Stunden:Minuten, auch bei mehr als 24 Stunden
|
||||
/// </summary>
|
||||
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) {
|
||||
if (value is null)
|
||||
return "0:0";
|
||||
if (value is int) {
|
||||
seconds = (int)value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Konvertiert eine Sekundenangabe nach Stunden:Minuten, auch bei mehr als 24 Stunden
|
||||
/// </summary>
|
||||
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) {
|
||||
if (value is null)
|
||||
return "0:0";
|
||||
if (value is int) {
|
||||
seconds = (int)value;
|
||||
}
|
||||
if (value is double) {
|
||||
seconds = (int)Math.Round((double)value);
|
||||
} else {
|
||||
int.TryParse((string?)value, out seconds);
|
||||
}
|
||||
if (value is double) {
|
||||
seconds = (int)Math.Round((double)value);
|
||||
} else {
|
||||
int.TryParse((string?)value, out seconds);
|
||||
}
|
||||
|
||||
TimeSpan time = TimeSpan.FromSeconds(seconds);
|
||||
TimeSpan time = TimeSpan.FromSeconds(seconds);
|
||||
|
||||
return (int)time.TotalHours + ":" + Math.Abs(time.Minutes);
|
||||
return (int)time.TotalHours + ":" + Math.Abs(time.Minutes);
|
||||
|
||||
//return time.ToString(@"hh\:mm");
|
||||
//return time.ToString(@"hh\:mm\:ss");
|
||||
//return time.ToString(@"hh\:mm");
|
||||
//return time.ToString(@"hh\:mm\:ss");
|
||||
|
||||
//return "00:00";
|
||||
}
|
||||
//return "00:00";
|
||||
}
|
||||
|
||||
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,17 @@
|
||||
using System.Globalization;
|
||||
|
||||
namespace Jugenddienst_Stunden.Converter;
|
||||
internal class StringVisibilityConverter : IValueConverter {
|
||||
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) {
|
||||
if (value is string strValue) {
|
||||
return !string.IsNullOrEmpty(strValue.Replace("Server: ",""));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
internal class StringVisibilityConverter : IValueConverter {
|
||||
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) {
|
||||
if (value is string strValue) {
|
||||
return !string.IsNullOrEmpty(strValue.Replace("Server: ", ""));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user