121 lines
3.1 KiB
C#
121 lines
3.1 KiB
C#
using CommunityToolkit.Mvvm.ComponentModel;
|
|
using CommunityToolkit.Mvvm.Input;
|
|
using System.Windows.Input;
|
|
using Microsoft.Maui.Controls;
|
|
using Microsoft.Maui.Networking;
|
|
using ZXing.Net.Maui;
|
|
using System.Collections.ObjectModel;
|
|
using System.ComponentModel;
|
|
|
|
|
|
namespace Jugenddienst_Stunden.ViewModels {
|
|
internal class StundenViewModel : ObservableObject {
|
|
public string Name => AppInfo.Name;
|
|
public string Surname => AppInfo.VersionString;
|
|
public string MoreInfoUrl => "https://aka.ms/maui";
|
|
public string Message => "Hier werden deine geleisteten Arbeitsstunden aufgelistet";
|
|
public ICommand LoadDataCommand { get; private set; }
|
|
public object Stunden { get; }
|
|
|
|
private Models.Hours _hour;
|
|
public Models.Hours Hours {
|
|
get => _hour;
|
|
}
|
|
public string ZeitDone {
|
|
get => _hour.zeit;
|
|
}
|
|
public string ZeitCalculated {
|
|
get => _hour.zeit_total;
|
|
}
|
|
public string Nominal {
|
|
get => _hour.nominal;
|
|
}
|
|
public string Overtime {
|
|
get => _hour.overtime;
|
|
}
|
|
public string OvertimeMonth {
|
|
get => _hour.overtime_month;
|
|
}
|
|
|
|
public Dictionary<int, decimal> ZeitTotalDaily {
|
|
get => _hour.zeit_total_daily;
|
|
}
|
|
|
|
public string Title { get; set; } = Preferences.Default.Get("name", "") + " " + Preferences.Default.Get("surname", "");
|
|
|
|
public ObservableCollection<string> Options { get; }
|
|
public ObservableCollection<string> OptionsProjekt { get; }
|
|
public ObservableCollection<string> OptionsFreistellung { get; }
|
|
private string selectedOption;
|
|
public string SelectedOption {
|
|
get => selectedOption;
|
|
set {
|
|
if (selectedOption != value) {
|
|
selectedOption = value;
|
|
OnPropertyChanged(nameof(SelectedOption));
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
public StundenViewModel() {
|
|
|
|
|
|
Options = new ObservableCollection<string> {
|
|
"Gemeinde 1",
|
|
"Gemeinde 2",
|
|
"Gemeinde 3",
|
|
"Gemeinde 4"
|
|
};
|
|
OptionsProjekt = new ObservableCollection<string> {
|
|
"Projekt 1",
|
|
"Projekt 2",
|
|
"Projekt 3"
|
|
};
|
|
OptionsFreistellung = new ObservableCollection<string> {
|
|
"Urlaub",
|
|
"Krankheit",
|
|
"Elternzeit"
|
|
};
|
|
_hour = new Models.Hours();
|
|
LoadDataCommand = new AsyncRelayCommand(LoadData);
|
|
|
|
}
|
|
|
|
//protected void OnPropertyChanged(string propertyName) {
|
|
// PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
|
//}
|
|
|
|
//public async Task LoadData() =>
|
|
// await Models.Stunde.LoadData();
|
|
|
|
public event EventHandler<string> AlertEvent;
|
|
|
|
public async Task LoadData() {
|
|
try {
|
|
_hour = await Models.Stunde.LoadData();
|
|
} catch (Exception e) {
|
|
AlertEvent?.Invoke(this, e.Message);
|
|
}
|
|
//Models.Hours Hours = new Models.Hours();
|
|
//Title = _hour.operator_api.name + " " + _hour.operator_api.surname;
|
|
if (_hour != null) {
|
|
RefreshProperties();
|
|
}
|
|
}
|
|
|
|
private void RefreshProperties() {
|
|
OnPropertyChanged(nameof(Nominal));
|
|
OnPropertyChanged(nameof(Overtime));
|
|
OnPropertyChanged(nameof(OvertimeMonth));
|
|
OnPropertyChanged(nameof(ZeitCalculated));
|
|
OnPropertyChanged(nameof(ZeitDone));
|
|
OnPropertyChanged(nameof(Hours));
|
|
OnPropertyChanged(nameof(Title));
|
|
OnPropertyChanged(nameof(ZeitTotalDaily));
|
|
}
|
|
|
|
|
|
}
|
|
}
|