Bei neuem Eintrag die vorhandenen anzeigen.
This commit is contained in:
@@ -3,6 +3,7 @@ using CommunityToolkit.Mvvm.Input;
|
||||
using Jugenddienst_Stunden.Types;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Windows.Input;
|
||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||
|
||||
namespace Jugenddienst_Stunden.ViewModels;
|
||||
internal class StundeViewModel : ObservableObject, IQueryAttributable {
|
||||
@@ -15,6 +16,7 @@ internal class StundeViewModel : ObservableObject, IQueryAttributable {
|
||||
private DayTime _stunde;
|
||||
public DayTime Stunde { get => _stunde; }
|
||||
|
||||
public string Title { get; set; } = "Eintrag bearbeiten";
|
||||
|
||||
public event EventHandler<string> AlertEvent;
|
||||
public event EventHandler<string> InfoEvent;
|
||||
@@ -60,7 +62,7 @@ internal class StundeViewModel : ObservableObject, IQueryAttributable {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public List<DayTime> DayTimes {get;set; }
|
||||
|
||||
|
||||
public ICommand SaveCommand { get; private set; }
|
||||
@@ -137,7 +139,7 @@ internal class StundeViewModel : ObservableObject, IQueryAttributable {
|
||||
|
||||
//DateTime heute = DateTime.Now;
|
||||
_stunde = await Models.Stunde.LoadEntry(Convert.ToInt32(query["load"]));
|
||||
if (String.IsNullOrEmpty(_stunde.description)) {
|
||||
if (System.String.IsNullOrEmpty(_stunde.description)) {
|
||||
AlertEvent?.Invoke(this, "Eintrag hat keine Daten zurückgegeben");
|
||||
}
|
||||
SubTitle = _stunde.day.ToString("dddd, d. MMM. yyyy");
|
||||
@@ -165,10 +167,21 @@ internal class StundeViewModel : ObservableObject, IQueryAttributable {
|
||||
|
||||
}
|
||||
if (query.ContainsKey("date")) {
|
||||
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);
|
||||
Title = "Neuer Eintrag";
|
||||
|
||||
DateTime _date = DateTime.ParseExact((string)query["date"], "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture);
|
||||
|
||||
//Bei neuem Eintrag die vorhandenen des gleichen Tages anzeigen
|
||||
DayTimes = await Models.Stunde.LoadDay(_date);
|
||||
|
||||
|
||||
_stunde.day = _date;
|
||||
SubTitle = _date.ToString("dddd, d. MMM. yyyy");
|
||||
|
||||
_ = LoadData();
|
||||
OnPropertyChanged(nameof(Title));
|
||||
OnPropertyChanged(nameof(SubTitle));
|
||||
OnPropertyChanged(nameof(DayTimes));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user