ServiceRecord-Fremdschlüssel zu NewSchedulerAppointment-Tabelle hinzugefügt. Funktionalität ist noch nicht implementiert. MoK: Ziele/Maßnahmen verbessert; Suche funktioniert jetzt richtig Mehrfachbuchung implementiert Kalender: Termine sind jetzt löschbar, wenn Recht zu bearbeiten vorhanden ist. Unterscheidung zwischen Mitarbeiter-, Klienten-, und Ressourcenauswahl bei Ansicht und Formular
134 lines
3.9 KiB
C#
134 lines
3.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using BS.Shared.DataContracts;
|
|
|
|
namespace BS.Shared.Core
|
|
{
|
|
public class UserSettingsUtils
|
|
{
|
|
public static string CreateNewSettingValue(string settings, string key, string val)
|
|
{
|
|
if(string.IsNullOrEmpty(settings))
|
|
{
|
|
return key + "=" + val;
|
|
}
|
|
|
|
var keyValuePairs = settings.Split(';');
|
|
var newValue = string.Empty;
|
|
|
|
foreach(var pair in keyValuePairs)
|
|
{
|
|
if(pair.IndexOf(key + "=") != 0)
|
|
{
|
|
if(newValue.Length > 0)
|
|
{
|
|
newValue += ";";
|
|
}
|
|
|
|
newValue += pair;
|
|
}
|
|
}
|
|
|
|
if(newValue.Length > 0)
|
|
{
|
|
newValue += ";";
|
|
}
|
|
|
|
newValue += key + "=" + val;
|
|
|
|
return newValue;
|
|
}
|
|
|
|
public static string GetSettingValue(string settings, string key)
|
|
{
|
|
if(!string.IsNullOrEmpty(settings))
|
|
{
|
|
if(settings.IndexOf(";") == -1 && settings.IndexOf("=") == -1)
|
|
{
|
|
return settings;
|
|
}
|
|
|
|
var keyValuePairs = settings.Split(';');
|
|
|
|
return (from pair in keyValuePairs select pair.Split('=') into keyValuePair where keyValuePair.Length == 2 where keyValuePair[0] == key select keyValuePair[1]).FirstOrDefault();
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
public static SettingsDC GetSettingValue(SettingsType pType, List<SettingsDC> pSettings)
|
|
{
|
|
return pSettings?.FirstOrDefault(s => s.Type == pType);
|
|
}
|
|
|
|
public static string GetSettingValue(SettingsType pType, string key, List<SettingsDC> pSettings)
|
|
{
|
|
var dc = GetSettingValue(pType, pSettings);
|
|
|
|
return dc != null ? GetSettingValue(dc.Value, key) : null;
|
|
}
|
|
|
|
public static void SetSettingValue(SettingsType pType, string key, string val, List<SettingsDC> pSettings)
|
|
{
|
|
var dc = GetSettingValue(pType, pSettings);
|
|
|
|
if(dc == null)
|
|
{
|
|
var newDc = new SettingsDC { Type = pType, Value = CreateNewSettingValue(string.Empty, key, val) };
|
|
pSettings.Add(newDc);
|
|
}
|
|
else
|
|
{
|
|
dc.Value = CreateNewSettingValue(dc.Value, key, val);
|
|
}
|
|
}
|
|
|
|
public static bool GetSettingValueAsBool(string settings, string key)
|
|
{
|
|
var stringValue = GetSettingValue(settings, key);
|
|
|
|
return "1" == stringValue;
|
|
}
|
|
|
|
public static int GetSettingValueAsInteger(string settings, string key, int defaultResult = 0)
|
|
{
|
|
var stringValue = GetSettingValue(settings, key);
|
|
|
|
var didParse = int.TryParse(stringValue, out var result);
|
|
|
|
return didParse ? result : defaultResult;
|
|
}
|
|
|
|
public static double GetSettingValueAsDouble(string settings, string key, double defaultResult = 0d)
|
|
{
|
|
var stringValue = GetSettingValue(settings, key);
|
|
|
|
var didParse = double.TryParse(stringValue, out var result);
|
|
|
|
return didParse ? result : defaultResult;
|
|
}
|
|
|
|
public static long GetSettingValueAsLong(string settings, string key, long defaultResult = 0L)
|
|
{
|
|
var stringValue = GetSettingValue(settings, key);
|
|
|
|
var didParse = long.TryParse(stringValue, out var result);
|
|
|
|
return didParse ? result : defaultResult;
|
|
}
|
|
|
|
public static DateTime? GetSettingValueAsDateTime(string settings, string key)
|
|
{
|
|
var stringValue = GetSettingValue(settings, key);
|
|
|
|
if(DateTime.TryParse(stringValue, out var result))
|
|
{
|
|
return result;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|
|
}
|