Daten speichern

This commit is contained in:
2024-09-25 22:22:05 +02:00
parent 3f2191673e
commit 8f7e4bb09e
6 changed files with 46 additions and 58 deletions

View File

@@ -136,7 +136,7 @@ namespace Jugenddienst_Stunden.Models {
var tokendata = new TokenData(apiKey);
await Auth.SaveItemAsync(tokendata.url, tokendata.apiKey, stunde,false);
return null;
return stunde;
}
}
}

View File

@@ -2,26 +2,38 @@
using System.Collections.ObjectModel;
namespace Jugenddienst_Stunden.Types {
/// <summary>
/// Represents a day time entry for an employee.
/// </summary>
public class DayTime {
public int? id;
public int EmployeeId;
public DateTime day;
public int wday;
public int? id { get; set; }
public int EmployeeId { get; set; }
public DateTime day { get; set; }
public int wday { get; set; }
public TimeOnly begin { get; set; }
public TimeOnly end { get; set; }
public string description { get; set; }
public string? free;
public bool? approved;
public int? type;
public int? projekt;
public int? gemeinde;
public TimeOnly night;
public Dictionary<string, TimeOnly> total;
public TimeOnly end_print;
public string? free { get; set; }
public bool? approved { get; set; }
public int? type { get; set; }
public int? projekt { get; set; }
public int? gemeinde { get; set; }
public TimeOnly night { get; set; }
public Dictionary<string, TimeOnly> total { get; set; }
public TimeOnly end_print { get; set; }
public TimeSpan TimeSpanVon { get; set; }
public TimeSpan TimeSpanBis { get; set; }
public Collection<Projekt> Projekte { get; set; }
public Collection<Gemeinde> Gemeinden { get; set; }
/// <summary>
/// Gets the active Gemeinde based on the gemeinde ID.
/// </summary>
public Gemeinde GemeindeAktiv { get; set; }
/// <summary>
/// Gets the active Projekt based on the projekt ID.
/// </summary>
public Projekt ProjektAktiv { get; set; }
}
}

View File

@@ -21,7 +21,6 @@ namespace Jugenddienst_Stunden.ViewModels {
private DayTime _stunde;
public DayTime Stunde { get => _stunde; }
public int Identifier => (int)_stunde.id;
public event EventHandler<string> AlertEvent;
@@ -29,24 +28,25 @@ namespace Jugenddienst_Stunden.ViewModels {
public ObservableCollection<Projekt> OptionsProjekt { get; private set; }
public ObservableCollection<string> OptionsFreistellung { get; }
private Gemeinde _selectedGemeinde;
//private Gemeinde _selectedGemeinde;
public Gemeinde SelectedOptionGemeinde {
get => _selectedGemeinde;
get => _stunde.GemeindeAktiv;
set {
if (_selectedGemeinde != value) {
_selectedGemeinde = value;
if (_stunde.GemeindeAktiv != value) {
//_selectedGemeinde = value;
_stunde.GemeindeAktiv = value;
OnPropertyChanged(nameof(SelectedOptionGemeinde));
}
}
}
private Projekt _selectedProjekt;
//private Projekt _selectedProjekt;
public Projekt SelectedOptionProjekt {
get => _selectedProjekt;
get => _stunde.ProjektAktiv;
set {
if (_selectedProjekt != value) {
_selectedProjekt = value;
//new AsyncRelayCommand(LoadData);
if (_stunde.ProjektAktiv != value) {
//_selectedProjekt = value;
_stunde.ProjektAktiv = value;
OnPropertyChanged(nameof(SelectedOptionProjekt));
}
}
@@ -58,7 +58,6 @@ namespace Jugenddienst_Stunden.ViewModels {
set {
if (selectedFreistellung != value) {
selectedFreistellung = value;
//new AsyncRelayCommand(LoadData);
OnPropertyChanged(nameof(SelectedOptionFreistellung));
}
}
@@ -93,10 +92,10 @@ namespace Jugenddienst_Stunden.ViewModels {
public StundeViewModel() {
_stunde = new DayTime();
SaveCommand = new AsyncRelayCommand(Save);
//DeleteCommand = new AsyncRelayCommand(Delete);
OptionsFreistellung = new ObservableCollection<string> {
"Keine",
"Urlaub",
@@ -113,8 +112,6 @@ namespace Jugenddienst_Stunden.ViewModels {
}
async Task Save() {
//_stunde.day = DateTime.Now;
//_stunde.Save();
await Models.Stunde.SaveEntry(_stunde);
await Shell.Current.GoToAsync($"..?saved={_stunde.id}");
}

View File

@@ -53,6 +53,7 @@ namespace Jugenddienst_Stunden.ViewModels {
public string Holiday {
get => _hour.holiday;
}
public TimeOnly DayTotal { get; set; }
public List<DayTime> DayTimes {
@@ -154,6 +155,8 @@ namespace Jugenddienst_Stunden.ViewModels {
////if (_hour.zeit_total_daily_api != null) {
////TimeDay = _hour.zeit_total_daily_api.Where(static p => p.Day == GetDay.Day).ToList() ?? new List<TimeDay> { new TimeDay { Day = GetDay.Day, Hours = 0 } };
//RefreshProperties();
TimeSpan span = TimeSpan.Zero;
foreach (DayTime dt in _hour.daytime) {
span += dt.end - dt.begin;

View File

@@ -14,13 +14,13 @@
<Label Text="{Binding SubTitle}" />
<FlexLayout Direction="Row" AlignItems="Start" Wrap="Wrap" JustifyContent="SpaceBetween">
<Border Background="LightGreen" >
<Border>
<HorizontalStackLayout>
<Label Text="Beginn" TextColor="Gray" VerticalTextAlignment="Center" HorizontalTextAlignment="End" Padding="0,0,10,0" Margin="5,0,0,0" MinimumWidthRequest="60"></Label>
<TimePicker x:Name="TimeBegin" HorizontalOptions="Center" TextColor="Gray" Format="HH:mm" MinimumWidthRequest="80" Time="{Binding Stunde.TimeSpanVon}" Margin="0,0,0,-5" />
</HorizontalStackLayout>
</Border>
<Border Background="OrangeRed" >
<Border>
<HorizontalStackLayout>
<Label Text="Ende" TextColor="White" VerticalTextAlignment="Center" HorizontalTextAlignment="End" Padding="0,0,10,0" Margin="5,0,0,0" MinimumWidthRequest="60"></Label>
<TimePicker x:Name="TimeEnd" TextColor="White" Format="HH:mm" MinimumWidthRequest="80" Time="{Binding Stunde.TimeSpanBis}" Margin="0,0,0,-5" />

View File

@@ -49,9 +49,11 @@
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<HorizontalStackLayout Grid.Row="0" Grid.Column="0">
<Label Grid.Row="0" Grid.Column="0" Text="{Binding begin}"/>
<Label Text="bis" Padding="10,0,10,0"/>
<Label Grid.Row="0" Grid.Column="1" Text="{Binding end}"/>
<Label Grid.Column="0" Text="{Binding begin}"/>
<Label Text="bis" Padding="5,0,5,0"/>
<Label Text="{Binding end}"/>
<Label Text="{Binding GemeindeAktiv.Name}" Margin="10,0,0,0"/>
<Label Text="{Binding ProjektAktiv.Name}" Margin="10,0,0,0"/>
</HorizontalStackLayout>
<Label Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Text="{Binding description}" Padding="0,0,0,15"/>
@@ -61,32 +63,6 @@
</CollectionView>
<!--<ListView ItemsSource="{Binding DayTimes}" VerticalScrollBarVisibility="Never" ItemSelected="{Binding SelectEntryCommand}">-->
<!--<ListView ItemsSource="{Binding DayTimes}" VerticalScrollBarVisibility="Never">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Grid Padding="15,10,0,10">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<HorizontalStackLayout Grid.Row="0" Grid.Column="0">
<Label Grid.Row="0" Grid.Column="0" Text="{Binding begin}"/>
<Label Text="bis" Padding="10,0,10,0"/>
<Label Grid.Row="0" Grid.Column="1" Text="{Binding end}"/>
</HorizontalStackLayout>
<Label Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Text="{Binding description}" Padding="0,0,0,5"/>
</Grid>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>-->
<BoxView HeightRequest="1" Color="Red"/>