Add LINQ Query
Prepare Api for Queryable Lists instead of Dictionarys
This commit is contained in:
@@ -6,15 +6,18 @@ namespace Jugenddienst_Stunden.Models {
|
|||||||
public class Hours : ObservableObject {
|
public class Hours : ObservableObject {
|
||||||
public string zeit;
|
public string zeit;
|
||||||
public string nominal;
|
public string nominal;
|
||||||
public Dictionary<DateOnly,NominalDay> nominal_day_api;
|
//public Dictionary<DateOnly,NominalDay> nominal_day_api;
|
||||||
public Dictionary<int,NominalWeek> nominal_week_api;
|
public List<NominalDay> nominal_day_api;
|
||||||
|
//public Dictionary<int,NominalWeek> nominal_week_api;
|
||||||
|
public List<NominalWeek> nominal_week_api;
|
||||||
//public List<string> time_line;
|
//public List<string> time_line;
|
||||||
public string zeit_total;
|
public string zeit_total;
|
||||||
|
|
||||||
//https://stackoverflow.com/questions/29449641/deserialize-json-when-a-value-can-be-an-object-or-an-empty-array/29450279#29450279
|
//https://stackoverflow.com/questions/29449641/deserialize-json-when-a-value-can-be-an-object-or-an-empty-array/29450279#29450279
|
||||||
|
|
||||||
[JsonConverter(typeof(JsonSingleOrEmptyArrayConverter<Hours>))]
|
//[JsonConverter(typeof(JsonSingleOrEmptyArrayConverter<Hours>))]
|
||||||
public Dictionary<int,decimal> zeit_total_daily;
|
//public Dictionary<int,decimal> zeit_total_daily;
|
||||||
|
public List<TimeDay> zeit_total_daily_api;
|
||||||
//public List<string> wochensumme;
|
//public List<string> wochensumme;
|
||||||
public string overtime_month;
|
public string overtime_month;
|
||||||
public string overtime;
|
public string overtime;
|
||||||
|
|||||||
@@ -9,5 +9,6 @@ namespace Jugenddienst_Stunden.Models {
|
|||||||
public int day_number;
|
public int day_number;
|
||||||
public int month_number;
|
public int month_number;
|
||||||
public decimal hours;
|
public decimal hours;
|
||||||
|
public DateOnly date;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
12
Jugenddienst Stunden/Models/TimeDay.cs
Normal file
12
Jugenddienst Stunden/Models/TimeDay.cs
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Jugenddienst_Stunden.Models {
|
||||||
|
public class TimeDay {
|
||||||
|
public int Day { get; set; }
|
||||||
|
public decimal Hours { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,6 +6,7 @@ using Microsoft.Maui.Networking;
|
|||||||
using ZXing.Net.Maui;
|
using ZXing.Net.Maui;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using Jugenddienst_Stunden.Models;
|
||||||
|
|
||||||
|
|
||||||
namespace Jugenddienst_Stunden.ViewModels {
|
namespace Jugenddienst_Stunden.ViewModels {
|
||||||
@@ -37,8 +38,12 @@ namespace Jugenddienst_Stunden.ViewModels {
|
|||||||
get => _hour.overtime_month;
|
get => _hour.overtime_month;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Dictionary<int, decimal> ZeitTotalDaily {
|
//public Dictionary<int, decimal> ZeitTotalDaily {
|
||||||
get => _hour.zeit_total_daily;
|
// get => _hour.zeit_total_daily;
|
||||||
|
//}
|
||||||
|
|
||||||
|
public List<Models.TimeDay> ZeitTotalDaily {
|
||||||
|
get => _hour.zeit_total_daily_api;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Title { get; set; } = Preferences.Default.Get("name", "") + " " + Preferences.Default.Get("surname", "");
|
public string Title { get; set; } = Preferences.Default.Get("name", "") + " " + Preferences.Default.Get("surname", "");
|
||||||
@@ -46,6 +51,8 @@ namespace Jugenddienst_Stunden.ViewModels {
|
|||||||
public ObservableCollection<string> Options { get; }
|
public ObservableCollection<string> Options { get; }
|
||||||
public ObservableCollection<string> OptionsProjekt { get; }
|
public ObservableCollection<string> OptionsProjekt { get; }
|
||||||
public ObservableCollection<string> OptionsFreistellung { get; }
|
public ObservableCollection<string> OptionsFreistellung { get; }
|
||||||
|
public List<TimeDay> TimeDay { get; set; }
|
||||||
|
|
||||||
private string selectedOption;
|
private string selectedOption;
|
||||||
public string SelectedOption {
|
public string SelectedOption {
|
||||||
get => selectedOption;
|
get => selectedOption;
|
||||||
@@ -79,7 +86,7 @@ namespace Jugenddienst_Stunden.ViewModels {
|
|||||||
};
|
};
|
||||||
_hour = new Models.Hours();
|
_hour = new Models.Hours();
|
||||||
LoadDataCommand = new AsyncRelayCommand(LoadData);
|
LoadDataCommand = new AsyncRelayCommand(LoadData);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//protected void OnPropertyChanged(string propertyName) {
|
//protected void OnPropertyChanged(string propertyName) {
|
||||||
@@ -100,6 +107,7 @@ namespace Jugenddienst_Stunden.ViewModels {
|
|||||||
//Models.Hours Hours = new Models.Hours();
|
//Models.Hours Hours = new Models.Hours();
|
||||||
//Title = _hour.operator_api.name + " " + _hour.operator_api.surname;
|
//Title = _hour.operator_api.name + " " + _hour.operator_api.surname;
|
||||||
if (_hour != null) {
|
if (_hour != null) {
|
||||||
|
TimeDay = _hour.zeit_total_daily_api.Where(p => p.Day == 1).ToList();
|
||||||
RefreshProperties();
|
RefreshProperties();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -113,6 +121,7 @@ namespace Jugenddienst_Stunden.ViewModels {
|
|||||||
OnPropertyChanged(nameof(Hours));
|
OnPropertyChanged(nameof(Hours));
|
||||||
OnPropertyChanged(nameof(Title));
|
OnPropertyChanged(nameof(Title));
|
||||||
OnPropertyChanged(nameof(ZeitTotalDaily));
|
OnPropertyChanged(nameof(ZeitTotalDaily));
|
||||||
|
OnPropertyChanged(nameof(TimeDay));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -53,8 +53,9 @@
|
|||||||
<Label Text="Ende" Grid.Column="2" Background="Red" VerticalTextAlignment="Center" HorizontalTextAlignment="End" Padding="0,0,10,0"></Label>
|
<Label Text="Ende" Grid.Column="2" Background="Red" VerticalTextAlignment="Center" HorizontalTextAlignment="End" Padding="0,0,10,0"></Label>
|
||||||
<TimePicker HorizontalOptions="Center" Grid.Column="3" Background="Red" />
|
<TimePicker HorizontalOptions="Center" Grid.Column="3" Background="Red" />
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
|
<Label Text="Zeit an Tag 1:"></Label>
|
||||||
|
<Label Text="{Binding TimeDay[0].Hours}"></Label>
|
||||||
|
|
||||||
|
|
||||||
</VerticalStackLayout>
|
</VerticalStackLayout>
|
||||||
|
|||||||
Reference in New Issue
Block a user