Get Freistellung to work

This commit is contained in:
2024-09-27 10:36:35 +02:00
parent abe659ae31
commit ec7f563bc0
11 changed files with 36 additions and 23 deletions

View File

@@ -1,14 +1,18 @@
 
namespace Jugenddienst_Stunden { namespace Jugenddienst_Stunden {
public partial class App : Application { public partial class App : Application {
public App() { public App() {
InitializeComponent(); InitializeComponent();
MainPage = new AppShell(); MainPage = new AppShell();
} }
//protected override Window CreateWindow(IActivationState activationState) => //protected override Window CreateWindow(IActivationState activationState) =>
//new Window(new AppShell()) { //new Window(new AppShell()) {
// Width = 500, // Width = 500,

View File

@@ -70,6 +70,7 @@
<ApplicationId>com.danielpichler.jugenddienststunden</ApplicationId> <ApplicationId>com.danielpichler.jugenddienststunden</ApplicationId>
<ApplicationDisplayVersion>1.0.1</ApplicationDisplayVersion> <ApplicationDisplayVersion>1.0.1</ApplicationDisplayVersion>
<ApplicationVersion>2</ApplicationVersion> <ApplicationVersion>2</ApplicationVersion>
<DefineConstants>$(DefineConstants);DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION</DefineConstants>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net8.0-android34.0|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net8.0-android34.0|AnyCPU'">
@@ -100,6 +101,7 @@
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net8.0-windows10.0.19041.0|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net8.0-windows10.0.19041.0|AnyCPU'">
<ApplicationVersion>2</ApplicationVersion> <ApplicationVersion>2</ApplicationVersion>
<DefineConstants>$(DefineConstants);DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION</DefineConstants>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net8.0-windows10.0.19041.0|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net8.0-windows10.0.19041.0|AnyCPU'">

View File

@@ -1,4 +1,6 @@
//using BarcodeScanning; 
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.Maui.LifecycleEvents; using Microsoft.Maui.LifecycleEvents;
using ZXing.Net.Maui.Controls; using ZXing.Net.Maui.Controls;

View File

@@ -11,8 +11,6 @@ namespace Jugenddienst_Stunden.Models {
class Auth { class Auth {
public Hours hours;
public static async Task<string> GetApiDataWithAuthAsync(string url, string token) { public static async Task<string> GetApiDataWithAuthAsync(string url, string token) {
// Erstellen eines HttpClient-Objekts // Erstellen eines HttpClient-Objekts

View File

@@ -13,7 +13,6 @@ namespace Jugenddienst_Stunden.Models {
internal class Stunde : ObservableObject { internal class Stunde : ObservableObject {
public DateTime Date { get; set; } public DateTime Date { get; set; }
private static Hours Hours { get; set; }
//Default-Werte zum Testen //Default-Werte zum Testen

View File

@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Jugenddienst_Stunden.Types {
public class Base {
public Collection<Projekt> Projekte { get; set; }
public Collection<Gemeinde> Gemeinden { get; set; }
public Collection<Freistellung> Freistellungen { get; set; }
public int EmployeeId { get; set; }
public Hours Hours { get; set; }
public List<DayTime> daytime { get; set; }
}
}

View File

@@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace Jugenddienst_Stunden.Types { namespace Jugenddienst_Stunden.Types {
public class Freistellung { public class Freistellung {
public string Identifier { get; set; } public string Id { get; set; }
public string Name { get; set; } public string Name { get; set; }
} }
} }

View File

@@ -22,13 +22,9 @@ namespace Jugenddienst_Stunden.ViewModels {
public DayTime Stunde { get => _stunde; } public DayTime Stunde { get => _stunde; }
public event EventHandler<string> AlertEvent; public event EventHandler<string> AlertEvent;
public event EventHandler<string> InfoEvent; public event EventHandler<string> InfoEvent;
public Collection<Projekt> Projekte { get; set; }
public Collection<Gemeinde> Gemeinden { get; set; }
public Collection<Freistellung> Freistellungen { get; set; }
public ObservableCollection<Gemeinde> OptionsGemeinde { get; private set; } public ObservableCollection<Gemeinde> OptionsGemeinde { get; private set; }
public ObservableCollection<Projekt> OptionsProjekt { get; private set; } public ObservableCollection<Projekt> OptionsProjekt { get; private set; }
@@ -58,7 +54,7 @@ namespace Jugenddienst_Stunden.ViewModels {
} }
} }
//private string selectedFreistellung; //private Freistellung _selectedFreistellung;
public Freistellung SelectedOptionFreistellung { public Freistellung SelectedOptionFreistellung {
get => _stunde.FreistellungAktiv; get => _stunde.FreistellungAktiv;
set { set {
@@ -80,12 +76,10 @@ namespace Jugenddienst_Stunden.ViewModels {
public StundeViewModel() { public StundeViewModel() {
_stunde = new DayTime(); _stunde = new DayTime();
SaveCommand = new AsyncRelayCommand(Save); SaveCommand = new AsyncRelayCommand(Save);
DeleteCommand = new AsyncRelayCommand(Delete); DeleteCommand = new AsyncRelayCommand(Delete);
_ = LoadData();
} }
public StundeViewModel(DayTime stunde) { public StundeViewModel(DayTime stunde) {
@@ -152,7 +146,7 @@ namespace Jugenddienst_Stunden.ViewModels {
SelectedOptionProjekt = OptionsProjekt.FirstOrDefault(Projekt => Projekt.Id == _stunde.projekt) ?? new Projekt(); SelectedOptionProjekt = OptionsProjekt.FirstOrDefault(Projekt => Projekt.Id == _stunde.projekt) ?? new Projekt();
OnPropertyChanged(nameof(SelectedOptionProjekt)); OnPropertyChanged(nameof(SelectedOptionProjekt));
SelectedOptionFreistellung = OptionsFreistellung.FirstOrDefault(Freistellung => Freistellung.Identifier == _stunde.free) ?? new Freistellung(); SelectedOptionFreistellung = OptionsFreistellung.FirstOrDefault(Freistellung => Freistellung.Id == _stunde.free) ?? new Freistellung();
OnPropertyChanged(nameof(SelectedOptionFreistellung)); OnPropertyChanged(nameof(SelectedOptionFreistellung));
OnPropertyChanged(nameof(Stunde)); OnPropertyChanged(nameof(Stunde));
@@ -162,6 +156,7 @@ namespace Jugenddienst_Stunden.ViewModels {
if (query.ContainsKey("date")) { if (query.ContainsKey("date")) {
SubTitle = DateTime.ParseExact((string)query["date"], "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture).ToString("dddd, d. MMM. yyyy"); SubTitle = DateTime.ParseExact((string)query["date"], "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture).ToString("dddd, d. MMM. yyyy");
_stunde.day = DateTime.ParseExact((string)query["date"], "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture); _stunde.day = DateTime.ParseExact((string)query["date"], "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture);
_ = LoadData();
OnPropertyChanged(nameof(SubTitle)); OnPropertyChanged(nameof(SubTitle));
} }

View File

@@ -142,11 +142,6 @@ namespace Jugenddienst_Stunden.ViewModels {
} }
private async Task LoadData() { private async Task LoadData() {
try { try {
_hour = await Models.Stunde.LoadData(); _hour = await Models.Stunde.LoadData();
@@ -156,7 +151,7 @@ namespace Jugenddienst_Stunden.ViewModels {
} }
} }
private async Task LoadDay(DateTime date) { public async Task LoadDay(DateTime date) {
try { try {
_hour.daytime = await Models.Stunde.LoadDay(date); _hour.daytime = await Models.Stunde.LoadDay(date);
////if (_hour.zeit_total_daily_api != null) { ////if (_hour.zeit_total_daily_api != null) {

View File

@@ -33,7 +33,7 @@
</Picker> </Picker>
<Picker x:Name="pick_projekt" Title="Projekt" ItemsSource="{Binding OptionsProjekt}" SelectedItem="{Binding SelectedOptionProjekt, Mode=TwoWay}" ItemDisplayBinding="{Binding Name}" Grid.Column="1" > <Picker x:Name="pick_projekt" Title="Projekt" ItemsSource="{Binding OptionsProjekt}" SelectedItem="{Binding SelectedOptionProjekt, Mode=TwoWay}" ItemDisplayBinding="{Binding Name}" Grid.Column="1" >
</Picker> </Picker>
<Picker x:Name="pick_freistellung" Title="Freistellung" ItemsSource="{Binding OptionsFreistellung}" SelectedItem="{Binding SelectedOptionFreistellung, Mode=TwoWay}" Grid.Column="2" > <Picker x:Name="pick_freistellung" Title="Freistellung" ItemsSource="{Binding OptionsFreistellung}" SelectedItem="{Binding SelectedOptionFreistellung, Mode=TwoWay}" ItemDisplayBinding="{Binding Name}" Grid.Column="2" >
</Picker> </Picker>
</Grid> </Grid>

View File

@@ -54,6 +54,7 @@
<Label Text="{Binding end}"/> <Label Text="{Binding end}"/>
<Label Text="{Binding GemeindeAktiv.Name}" Margin="10,0,0,0"/> <Label Text="{Binding GemeindeAktiv.Name}" Margin="10,0,0,0"/>
<Label Text="{Binding ProjektAktiv.Name}" Margin="10,0,0,0"/> <Label Text="{Binding ProjektAktiv.Name}" Margin="10,0,0,0"/>
<Label Text="{Binding FreistellungAktiv.Name}" Margin="10,0,0,0"/>
</HorizontalStackLayout> </HorizontalStackLayout>
<Label Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Text="{Binding description}" Padding="0,0,0,15"/> <Label Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Text="{Binding description}" Padding="0,0,0,15"/>
@@ -63,10 +64,8 @@
</CollectionView> </CollectionView>
<BoxView HeightRequest="1" Color="Red"/> <BoxView HeightRequest="1" Color="Red"/>
<Button Text="{Binding LoadOverview}" Command="{Binding LoadDataCommand}" /> <Button Text="{Binding LoadOverview}" Command="{Binding LoadDataCommand}" />
<Grid RowDefinitions="Auto,Auto,Auto,Auto,Auto,*" ColumnDefinitions="Auto,*" Margin="10"> <Grid RowDefinitions="Auto,Auto,Auto,Auto,Auto,*" ColumnDefinitions="Auto,*" Margin="10">