using CommunityToolkit.Mvvm.ComponentModel; using Elwig.Helpers; using Elwig.Models.Entities; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Windows.Controls; namespace Elwig.ViewModels { public partial class DeliveryAdminViewModel : ObservableObject { public bool IsReceipt = false; [ObservableProperty] private string _title = "Lieferungen - Elwig"; public Member? FilterMember { get; set; } [ObservableProperty] private string? _searchQuery = ""; public List TextFilter => [.. SearchQuery?.ToLower().Split(' ').ToList().FindAll(e => e.Length > 0)]; [ObservableProperty] private string? _lastScaleError; [ObservableProperty] private string? _manualWeighingReason; [ObservableProperty] private string? _scaleId; [ObservableProperty] private string? _weighingData; [ObservableProperty] private bool _filterTodayOnly; [ObservableProperty] private bool _filterAllSeasons; [ObservableProperty] private bool _enableAllSeasons; [ObservableProperty] private string? _filterSeasonString; public int? FilterSeason { get => int.TryParse(FilterSeasonString, out var year) ? year : null; set => FilterSeasonString = $"{value}"; } [ObservableProperty] private Delivery? _selectedDelivery; [ObservableProperty] private IEnumerable _deliveries = []; [ObservableProperty] private string? _mgNrString; public int? MgNr { get => int.TryParse(MgNrString, out var mgnr) ? mgnr : null; set => MgNrString = $"{value}"; } [ObservableProperty] private Member? _member; [ObservableProperty] private IEnumerable _memberSource = []; [ObservableProperty] private string? _memberAddress; [ObservableProperty] private string? _lsNr; [ObservableProperty] private string? _date; [ObservableProperty] private string? _time; [ObservableProperty] private Branch? _branch; [ObservableProperty] private IEnumerable _branchSource = []; [ObservableProperty] private string? _comment; [ObservableProperty] private string? _sortId; [ObservableProperty] private WineVar? _wineVar; [ObservableProperty] private IEnumerable _wineVarSource = []; [ObservableProperty] private object? _wineAttrObj; public WineAttr? WineAttr { get => WineAttrObj as WineAttr; set => WineAttrObj = value ?? WineAttrSource.FirstOrDefault(); } [ObservableProperty] private IEnumerable _wineAttrSource = []; [ObservableProperty] private object? _wineCultObj; public WineCult? WineCult { get => WineCultObj as WineCult; set => WineCultObj = value ?? WineCultSource.FirstOrDefault(); } [ObservableProperty] private IEnumerable _wineCultSource = []; [ObservableProperty] private string? _gradationOeString; public double? GradationOe => double.TryParse(GradationOeString, out var oe) ? oe : null; [ObservableProperty] private string? _gradationKmwString; public double? GradationKmw => double.TryParse(GradationKmwString, out var kmw) ? kmw : null; [ObservableProperty] private WineQualLevel? _wineQualityLevel; [ObservableProperty] private IEnumerable _wineQualityLevelSource = []; [ObservableProperty] private bool _abgewertet; [ObservableProperty] private string? _weightString; public int? Weight { get => int.TryParse(WeightString?.Replace(Utils.GroupSeparator, ""), out var w) ? w : null; set => WeightString = $"{value:N0}"; } [ObservableProperty] private bool _isManualWeighing; [ObservableProperty] private bool? _isNetWeightValue = false; public bool IsNetWeight { get => IsNetWeightValue ?? false; set => IsNetWeightValue = value; } [ObservableProperty] private WineOrigin? _wineOrigin; [ObservableProperty] private IEnumerable _wineOriginSource = []; [ObservableProperty] private object? _wineKgObj; public AT_Kg? WineKg { get => WineKgObj as AT_Kg; set => WineKgObj = value ?? WineKgSource.FirstOrDefault(); } [ObservableProperty] private IEnumerable _wineKgSource = []; [ObservableProperty] private object? _wineRdObj; public WbRd? WineRd { get => WineRdObj as WbRd; set => WineRdObj = value ?? WineRdSource.FirstOrDefault(); } [ObservableProperty] private IEnumerable _wineRdSource = []; [ObservableProperty] private bool? _isGebunden; public ObservableCollection Modifiers { get; set; } = []; [ObservableProperty] private IEnumerable _modifiersSource = []; [ObservableProperty] private string? _partComment; [ObservableProperty] private string? _temperatureString; public double? Temperature => double.TryParse(TemperatureString, out var t) ? t : null; [ObservableProperty] private string? _acidString; public double? Acid => double.TryParse(AcidString, out var a) ? a : null; [ObservableProperty] private bool _isLesewagen; [ObservableProperty] private bool? _isHandPicked; [ObservableProperty] private string _statusMembers = "-"; [ObservableProperty] private string _statusDeliveries = "-"; [ObservableProperty] private string _statusVarieties = "-"; [ObservableProperty] private string _statusWeight = "-"; [ObservableProperty] private string _statusGradation = "-"; [ObservableProperty] private Grid? _statusWeightToolTip; [ObservableProperty] private Grid? _statusGradationToolTip; } }