using CommunityToolkit.Mvvm.ComponentModel; using LehrerApp.Desktop.Services; namespace LehrerApp.Desktop.ViewModels.Students; public sealed record AttendanceCalendarSizeChoice(AttendanceCalendarSize Value, string DisplayName); public partial class AttendanceCalendarConfigurationViewModel : ObservableObject { [ObservableProperty] private DateTimeOffset? _startMonth; [ObservableProperty] private int _monthCount; [ObservableProperty] private AttendanceCalendarSizeChoice _selectedSize; public IReadOnlyList MonthCounts { get; } = [1, 2, 3]; public IReadOnlyList Sizes { get; } = [ new(AttendanceCalendarSize.Small, "Klein"), new(AttendanceCalendarSize.Medium, "Standard"), new(AttendanceCalendarSize.Large, "Groß"), ]; public AttendanceCalendarConfigurationViewModel(AttendanceCalendarOptions options) { StartMonth = new DateTimeOffset(options.NormalizedStartMonth.ToDateTime(TimeOnly.MinValue)); MonthCount = options.NormalizedMonthCount; SelectedSize = Sizes.First(s => s.Value == options.Size); } public AttendanceCalendarOptions BuildResult() { var date = DateOnly.FromDateTime((StartMonth ?? DateTimeOffset.Now).LocalDateTime); return new AttendanceCalendarOptions(new DateOnly(date.Year, date.Month, 1), MonthCount, SelectedSize.Value); } }