Kapitel 7 abgeschlossen.
This commit is contained in:
@@ -0,0 +1,182 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using LehrerApp.Core.Interfaces;
|
||||
using LehrerApp.Core.Models;
|
||||
using LehrerApp.Core.Services;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Globalization;
|
||||
|
||||
namespace LehrerApp.Desktop.ViewModels.Students;
|
||||
|
||||
public partial class CreateLetterDialogViewModel : ObservableObject
|
||||
{
|
||||
private readonly Student _student;
|
||||
private readonly LetterTemplateService _templates;
|
||||
|
||||
[ObservableProperty] private LetterTemplateChoice? _selectedTemplate;
|
||||
[ObservableProperty] private LetterContactChoice? _selectedContact;
|
||||
[ObservableProperty] private LetterGroupChoice? _selectedGroup;
|
||||
[ObservableProperty] private DateTimeOffset? _letterDate = DateTimeOffset.Now;
|
||||
[ObservableProperty] private string _generationError = "";
|
||||
[ObservableProperty] private bool _canGenerate;
|
||||
|
||||
public string StudentName => _student.FullName;
|
||||
public ObservableCollection<LetterTemplateChoice> Templates { get; } = [];
|
||||
public ObservableCollection<LetterContactChoice> Contacts { get; } = [];
|
||||
public ObservableCollection<LetterGroupChoice> Groups { get; } = [];
|
||||
public ObservableCollection<LetterGenerationIssue> Issues { get; } = [];
|
||||
public bool HasIssues => Issues.Count > 0;
|
||||
public bool HasNoTemplates => Templates.Count == 0;
|
||||
public bool HasNoContacts => Contacts.Count == 0;
|
||||
public string SuggestedFileName => SanitizeFileName(
|
||||
$"{SelectedTemplate?.Name ?? "Elternbrief"}_{_student.LastName}_{_student.FirstName}.docx");
|
||||
|
||||
public CreateLetterDialogViewModel(Student student, LetterTemplateService templates,
|
||||
IGroupMembershipRepository memberships, IGroupRepository groups)
|
||||
{
|
||||
_student = student;
|
||||
_templates = templates;
|
||||
|
||||
foreach (var template in templates.GetTemplates())
|
||||
Templates.Add(new LetterTemplateChoice(template));
|
||||
foreach (var contact in student.Contacts.Where(c => !c.InvalidSince.HasValue).OrderBy(c => c.Name))
|
||||
Contacts.Add(new LetterContactChoice(contact));
|
||||
foreach (var membership in memberships.GetByStudent(student.Id))
|
||||
{
|
||||
var group = groups.GetById(membership.GroupId);
|
||||
if (group is not null) Groups.Add(new LetterGroupChoice(group));
|
||||
}
|
||||
|
||||
SelectedTemplate = Templates.FirstOrDefault();
|
||||
SelectedContact = Contacts.FirstOrDefault();
|
||||
SelectedGroup = Groups.FirstOrDefault();
|
||||
RefreshValidation();
|
||||
}
|
||||
|
||||
partial void OnSelectedTemplateChanged(LetterTemplateChoice? value)
|
||||
{
|
||||
OnPropertyChanged(nameof(SuggestedFileName));
|
||||
RefreshValidation();
|
||||
}
|
||||
partial void OnSelectedContactChanged(LetterContactChoice? value) => RefreshValidation();
|
||||
partial void OnSelectedGroupChanged(LetterGroupChoice? value) => RefreshValidation();
|
||||
partial void OnLetterDateChanged(DateTimeOffset? value) => RefreshValidation();
|
||||
|
||||
public bool Generate(string outputPath)
|
||||
{
|
||||
RefreshValidation();
|
||||
if (!CanGenerate || SelectedTemplate is null) return false;
|
||||
GenerationError = "";
|
||||
try
|
||||
{
|
||||
_templates.Generate(_templates.GetTemplatePath(SelectedTemplate.Model), outputPath, BuildValues());
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex) when (ex is IOException or InvalidDataException or UnauthorizedAccessException)
|
||||
{
|
||||
GenerationError = $"Der Brief konnte nicht erzeugt werden: {ex.Message}";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshValidation()
|
||||
{
|
||||
Issues.Clear();
|
||||
GenerationError = "";
|
||||
|
||||
if (SelectedTemplate is null)
|
||||
Issues.Add(new("Bitte zuerst in den Einstellungen eine DOCX-Briefvorlage importieren.", true));
|
||||
if (SelectedContact is null)
|
||||
Issues.Add(new("Für den Schüler ist kein aktueller Kontakt ausgewählt.", true));
|
||||
if (LetterDate is null)
|
||||
Issues.Add(new("Bitte ein Briefdatum auswählen.", true));
|
||||
|
||||
if (SelectedTemplate is not null)
|
||||
{
|
||||
var validation = _templates.Validate(SelectedTemplate.Model);
|
||||
foreach (var issue in validation.Issues)
|
||||
Issues.Add(new(issue.Message, issue.Severity is TemplateIssueSeverity.StrongWarning or TemplateIssueSeverity.Error));
|
||||
|
||||
var tags = validation.Tags.ToHashSet(StringComparer.Ordinal);
|
||||
var values = BuildValues();
|
||||
foreach (var tag in tags.Where(t => values.TryGetValue(t, out var value) && string.IsNullOrWhiteSpace(value)))
|
||||
{
|
||||
var message = tag switch
|
||||
{
|
||||
"Letter.Salutation" => "Beim ausgewählten Kontakt fehlt die Briefanrede.",
|
||||
"Contact.Address" or "Contact.Street" or "Contact.PostalCode" or "Contact.City" =>
|
||||
$"Beim ausgewählten Kontakt fehlt der Wert für „{tag}“.",
|
||||
"Group.Name" or "SchoolYear" => "Die Vorlage verwendet Gruppendaten; bitte eine Lerngruppe auswählen.",
|
||||
_ => $"Für das Vorlagenfeld „{tag}“ ist kein Wert vorhanden.",
|
||||
};
|
||||
Issues.Add(new(message, true));
|
||||
}
|
||||
}
|
||||
|
||||
CanGenerate = SelectedTemplate is not null && SelectedContact is not null && LetterDate is not null
|
||||
&& Issues.Count == 0;
|
||||
OnPropertyChanged(nameof(HasIssues));
|
||||
}
|
||||
|
||||
private IReadOnlyDictionary<string, string?> BuildValues()
|
||||
{
|
||||
var contact = SelectedContact?.Model;
|
||||
var group = SelectedGroup?.Model;
|
||||
var cityLine = string.Join(" ", new[] { contact?.PostalCode, contact?.City }
|
||||
.Where(v => !string.IsNullOrWhiteSpace(v)));
|
||||
var address = string.Join(Environment.NewLine, new[] { contact?.Street, cityLine }
|
||||
.Where(v => !string.IsNullOrWhiteSpace(v)));
|
||||
var date = LetterDate is null ? null : DateOnly.FromDateTime(LetterDate.Value.LocalDateTime)
|
||||
.ToString("dd.MM.yyyy", CultureInfo.GetCultureInfo("de-DE"));
|
||||
|
||||
return new Dictionary<string, string?>
|
||||
{
|
||||
["Student.FirstName"] = _student.FirstName,
|
||||
["Student.LastName"] = _student.LastName,
|
||||
["Contact.Name"] = contact?.Name,
|
||||
["Contact.Address"] = address,
|
||||
["Contact.Street"] = contact?.Street,
|
||||
["Contact.PostalCode"] = contact?.PostalCode,
|
||||
["Contact.City"] = contact?.City,
|
||||
["Letter.Salutation"] = contact?.LetterSalutation,
|
||||
["Group.Name"] = group?.Name,
|
||||
["SchoolYear"] = group?.SchoolYear,
|
||||
["CurrentDate"] = date,
|
||||
};
|
||||
}
|
||||
|
||||
private static string SanitizeFileName(string value)
|
||||
{
|
||||
foreach (var character in Path.GetInvalidFileNameChars()) value = value.Replace(character, '_');
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class LetterTemplateChoice
|
||||
{
|
||||
public LetterTemplateInfo Model { get; }
|
||||
public string Name => Model.Name;
|
||||
public LetterTemplateChoice(LetterTemplateInfo model) => Model = model;
|
||||
}
|
||||
|
||||
public sealed class LetterContactChoice
|
||||
{
|
||||
public Contact Model { get; }
|
||||
public string Display => string.IsNullOrWhiteSpace(Model.Relation)
|
||||
? Model.Name
|
||||
: $"{Model.Name} · {Model.Relation}";
|
||||
public LetterContactChoice(Contact model) => Model = model;
|
||||
}
|
||||
|
||||
public sealed class LetterGroupChoice
|
||||
{
|
||||
public LearningGroup Model { get; }
|
||||
public string Display => $"{Model.Name} · {Model.SchoolYear}";
|
||||
public LetterGroupChoice(LearningGroup model) => Model = model;
|
||||
}
|
||||
|
||||
public sealed class LetterGenerationIssue(string message, bool isStrong)
|
||||
{
|
||||
public string Icon { get; } = isStrong ? "⚠" : "ⓘ";
|
||||
public string Message { get; } = message;
|
||||
public string Color { get; } = isStrong ? "#D97706" : "#6B7280";
|
||||
}
|
||||
@@ -9,9 +9,56 @@ using System.Globalization;
|
||||
|
||||
namespace LehrerApp.Desktop.ViewModels.Students;
|
||||
|
||||
public static class GenderAvatarDisplay
|
||||
{
|
||||
public static List<string> Options { get; } = ["", "M – männlich", "W – weiblich", "D – divers"];
|
||||
|
||||
public static string Label(Gender? gender) => gender switch
|
||||
{
|
||||
Gender.M => "M",
|
||||
Gender.W => "W",
|
||||
Gender.D => "D",
|
||||
_ => "?",
|
||||
};
|
||||
|
||||
public static string Color(Gender? gender) => gender switch
|
||||
{
|
||||
Gender.M => "#3B82F6",
|
||||
Gender.W => "#A855F7",
|
||||
Gender.D => "#0D9488",
|
||||
_ => "#6B7280",
|
||||
};
|
||||
|
||||
public static string Tooltip(Gender? gender) => gender switch
|
||||
{
|
||||
Gender.M => "Geschlecht: männlich",
|
||||
Gender.W => "Geschlecht: weiblich",
|
||||
Gender.D => "Geschlecht: divers",
|
||||
_ => "Geschlecht nicht angegeben",
|
||||
};
|
||||
|
||||
public static string ToOption(Gender? gender) => gender switch
|
||||
{
|
||||
Gender.M => "M – männlich",
|
||||
Gender.W => "W – weiblich",
|
||||
Gender.D => "D – divers",
|
||||
_ => "",
|
||||
};
|
||||
|
||||
public static Gender? FromOption(string? option) => option switch
|
||||
{
|
||||
"M – männlich" => Gender.M,
|
||||
"W – weiblich" => Gender.W,
|
||||
"D – divers" => Gender.D,
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
public partial class StudentListViewModel : ObservableObject
|
||||
{
|
||||
private readonly IStudentRepository _students;
|
||||
private readonly IGroupRepository _groups;
|
||||
private readonly IGroupMembershipRepository _memberships;
|
||||
public Action<Guid>? OnNavigateToDetail { get; set; }
|
||||
|
||||
[ObservableProperty] private string _searchText = "";
|
||||
@@ -21,9 +68,12 @@ public partial class StudentListViewModel : ObservableObject
|
||||
public ObservableCollection<StudentListItem> Students { get; } = [];
|
||||
public string CountSummary => $"{Students.Count} Schüler gesamt";
|
||||
|
||||
public StudentListViewModel(IStudentRepository students)
|
||||
public StudentListViewModel(IStudentRepository students, IGroupRepository groups,
|
||||
IGroupMembershipRepository memberships)
|
||||
{
|
||||
_students = students;
|
||||
_groups = groups;
|
||||
_memberships = memberships;
|
||||
LoadStudents();
|
||||
}
|
||||
|
||||
@@ -38,9 +88,21 @@ public partial class StudentListViewModel : ObservableObject
|
||||
{
|
||||
Students.Clear();
|
||||
var all = _students.GetAll(ShowInactive);
|
||||
var f = string.IsNullOrWhiteSpace(SearchText) ? all
|
||||
: all.Where(s => s.LastName.Contains(SearchText, StringComparison.OrdinalIgnoreCase)
|
||||
|| s.FirstName.Contains(SearchText, StringComparison.OrdinalIgnoreCase));
|
||||
var query = SearchText.Trim();
|
||||
IEnumerable<Student> f = all;
|
||||
if (query.Length > 0)
|
||||
{
|
||||
var matchingStudentIds = _groups.GetAll(includeInactive: true)
|
||||
.Where(g => g.Name.Contains(query, StringComparison.OrdinalIgnoreCase))
|
||||
.SelectMany(g => _memberships.GetByGroup(g.Id))
|
||||
.Select(m => m.StudentId)
|
||||
.ToHashSet();
|
||||
|
||||
f = all.Where(s => s.LastName.Contains(query, StringComparison.OrdinalIgnoreCase)
|
||||
|| s.FirstName.Contains(query, StringComparison.OrdinalIgnoreCase)
|
||||
|| s.FullName.Contains(query, StringComparison.OrdinalIgnoreCase)
|
||||
|| matchingStudentIds.Contains(s.Id));
|
||||
}
|
||||
foreach (var s in f) Students.Add(new StudentListItem(s));
|
||||
OnPropertyChanged(nameof(CountSummary));
|
||||
}
|
||||
@@ -63,10 +125,92 @@ public class StudentListItem
|
||||
public Guid Id { get; }
|
||||
public string FullName { get; }
|
||||
public string DateOfBirth { get; }
|
||||
public string AvatarLabel { get; }
|
||||
public string AvatarColor { get; }
|
||||
public string AvatarTooltip { get; }
|
||||
public StudentListItem(Student s)
|
||||
{
|
||||
Id = s.Id; FullName = s.FullName;
|
||||
DateOfBirth = s.DateOfBirth?.ToString("dd.MM.yyyy") ?? "";
|
||||
AvatarLabel = GenderAvatarDisplay.Label(s.Gender);
|
||||
AvatarColor = GenderAvatarDisplay.Color(s.Gender);
|
||||
AvatarTooltip = GenderAvatarDisplay.Tooltip(s.Gender);
|
||||
}
|
||||
}
|
||||
|
||||
public enum StudentManagementResult { Cancelled, Deactivated, Reactivated, Deleted }
|
||||
|
||||
public class StudentReferenceItem(string label, int count)
|
||||
{
|
||||
public string Label { get; } = label;
|
||||
public int Count { get; } = count;
|
||||
public string CountDisplay => Count.ToString(CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
public partial class ManageStudentDialogViewModel : ObservableObject
|
||||
{
|
||||
private readonly IStudentRepository _students;
|
||||
private readonly Student _student;
|
||||
|
||||
[ObservableProperty] private string _errorMessage = "";
|
||||
|
||||
public string StudentName => _student.FullName;
|
||||
public bool IsActive => _student.IsActive;
|
||||
public bool IsInactive => !IsActive;
|
||||
public StudentReferenceSummary References { get; }
|
||||
public bool HasReferences => References.HasReferences;
|
||||
public bool CanDelete => !HasReferences;
|
||||
public ObservableCollection<StudentReferenceItem> ReferenceItems { get; } = [];
|
||||
public StudentManagementResult Result { get; private set; }
|
||||
|
||||
public ManageStudentDialogViewModel(IStudentRepository students, Student student)
|
||||
{
|
||||
_students = students;
|
||||
_student = student;
|
||||
References = students.GetReferenceSummary(student.Id);
|
||||
|
||||
AddReference("Gruppenzuordnungen", References.Memberships);
|
||||
AddReference("Klausurergebnisse", References.ExamResults);
|
||||
AddReference("Einzelnoten", References.Grades);
|
||||
AddReference("Zeugnisnoten", References.ReportGrades);
|
||||
AddReference("Mitarbeitseinträge", References.ParticipationEntries);
|
||||
AddReference("Dokumentationseinträge", References.DocumentationEntries);
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private void Deactivate()
|
||||
{
|
||||
_student.IsActive = false;
|
||||
_students.Save(_student);
|
||||
Result = StudentManagementResult.Deactivated;
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private void Reactivate()
|
||||
{
|
||||
_student.IsActive = true;
|
||||
_students.Save(_student);
|
||||
Result = StudentManagementResult.Reactivated;
|
||||
}
|
||||
|
||||
[RelayCommand(CanExecute = nameof(CanDelete))]
|
||||
private void DeletePermanently()
|
||||
{
|
||||
ErrorMessage = "";
|
||||
try
|
||||
{
|
||||
_students.Delete(_student.Id);
|
||||
Result = StudentManagementResult.Deleted;
|
||||
}
|
||||
catch (InvalidOperationException ex)
|
||||
{
|
||||
ErrorMessage = ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private void AddReference(string label, int count)
|
||||
{
|
||||
if (count > 0) ReferenceItems.Add(new StudentReferenceItem(label, count));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,9 +235,17 @@ public partial class StudentDetailViewModel : ObservableObject
|
||||
[ObservableProperty] private bool _isEditing;
|
||||
[ObservableProperty] private string _editFirstName = "";
|
||||
[ObservableProperty] private string _editLastName = "";
|
||||
[ObservableProperty] private string _editGender = "";
|
||||
[ObservableProperty] private ContactItem? _selectedContact;
|
||||
[ObservableProperty] private AttendanceBalance? _attendance;
|
||||
[ObservableProperty] private string _exportStatus = "";
|
||||
[ObservableProperty] private bool _isStudentActive = true;
|
||||
|
||||
public string StudentStatus => IsStudentActive ? "Aktiv" : "Inaktiv";
|
||||
public List<string> GenderOptions => GenderAvatarDisplay.Options;
|
||||
public string StudentAvatarLabel => GenderAvatarDisplay.Label(Student?.Gender);
|
||||
public string StudentAvatarColor => GenderAvatarDisplay.Color(Student?.Gender);
|
||||
public string StudentAvatarTooltip => GenderAvatarDisplay.Tooltip(Student?.Gender);
|
||||
|
||||
public ObservableCollection<GroupMembershipEntry> GroupMemberships { get; } = [];
|
||||
public ObservableCollection<DocumentationItem> Documentation { get; } = [];
|
||||
@@ -106,6 +258,11 @@ public partial class StudentDetailViewModel : ObservableObject
|
||||
public Func<DocumentationItem, Task<bool>>? OnConfirmDeleteDocumentation { get; set; }
|
||||
public Func<string, Task>? OnSaveExportFile { get; set; }
|
||||
public Func<Documentation, string, Task<Documentation?>>? OnConductParentCall { get; set; }
|
||||
public Func<Student, Task<StudentManagementResult>>? OnManageStudent { get; set; }
|
||||
public Func<Task>? OnCreateLetter { get; set; }
|
||||
public Action? OnReturnToStudentList { get; set; }
|
||||
|
||||
partial void OnIsStudentActiveChanged(bool value) => OnPropertyChanged(nameof(StudentStatus));
|
||||
|
||||
public StudentDetailViewModel(IStudentRepository students,
|
||||
IGroupMembershipRepository memberships, IGroupRepository groups, ISubjectRepository subjects,
|
||||
@@ -126,8 +283,13 @@ public partial class StudentDetailViewModel : ObservableObject
|
||||
Student = _students.GetById(id);
|
||||
if (Student is null) return;
|
||||
StudentTitle = Student.FullName;
|
||||
IsStudentActive = Student.IsActive;
|
||||
EditFirstName = Student.FirstName;
|
||||
EditLastName = Student.LastName;
|
||||
EditGender = GenderAvatarDisplay.ToOption(Student.Gender);
|
||||
OnPropertyChanged(nameof(StudentAvatarLabel));
|
||||
OnPropertyChanged(nameof(StudentAvatarColor));
|
||||
OnPropertyChanged(nameof(StudentAvatarTooltip));
|
||||
|
||||
GroupMemberships.Clear();
|
||||
GradeHistory.Clear();
|
||||
@@ -269,18 +431,44 @@ public partial class StudentDetailViewModel : ObservableObject
|
||||
}
|
||||
|
||||
[RelayCommand] private void StartEdit() => IsEditing = true;
|
||||
|
||||
[RelayCommand]
|
||||
private async Task CreateLetter()
|
||||
{
|
||||
if (Student is not null && OnCreateLetter is not null) await OnCreateLetter();
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private async Task ManageStudent()
|
||||
{
|
||||
if (Student is null || OnManageStudent is null) return;
|
||||
var result = await OnManageStudent(Student);
|
||||
if (result == StudentManagementResult.Deleted)
|
||||
{
|
||||
OnReturnToStudentList?.Invoke();
|
||||
return;
|
||||
}
|
||||
if (result is StudentManagementResult.Deactivated or StudentManagementResult.Reactivated)
|
||||
LoadStudent(Student.Id);
|
||||
}
|
||||
|
||||
[RelayCommand] private void CancelEdit()
|
||||
{
|
||||
if (Student is null) return;
|
||||
EditFirstName = Student.FirstName; EditLastName = Student.LastName;
|
||||
EditGender = GenderAvatarDisplay.ToOption(Student.Gender);
|
||||
IsEditing = false;
|
||||
}
|
||||
[RelayCommand] private void SaveEdit()
|
||||
{
|
||||
if (Student is null) return;
|
||||
Student.FirstName = EditFirstName; Student.LastName = EditLastName;
|
||||
Student.Gender = GenderAvatarDisplay.FromOption(EditGender);
|
||||
_students.Save(Student);
|
||||
StudentTitle = Student.FullName;
|
||||
OnPropertyChanged(nameof(StudentAvatarLabel));
|
||||
OnPropertyChanged(nameof(StudentAvatarColor));
|
||||
OnPropertyChanged(nameof(StudentAvatarTooltip));
|
||||
IsEditing = false;
|
||||
}
|
||||
|
||||
@@ -382,6 +570,7 @@ public class ContactItem
|
||||
public Guid Id => Model.Id;
|
||||
public string Name { get; }
|
||||
public string Relation { get; }
|
||||
public string LetterSalutation { get; }
|
||||
public string? Phone { get; }
|
||||
public string? Email { get; }
|
||||
public string Address { get; }
|
||||
@@ -404,6 +593,7 @@ public class ContactItem
|
||||
Model = c;
|
||||
Name = c.Name;
|
||||
Relation = c.Relation;
|
||||
LetterSalutation = c.LetterSalutation ?? "";
|
||||
Phone = c.Phone;
|
||||
Email = c.Email;
|
||||
Address = FormatAddress(c);
|
||||
@@ -449,7 +639,7 @@ public partial class AddStudentDialogViewModel : ObservableObject
|
||||
[ObservableProperty] private string _firstNameError = "";
|
||||
[ObservableProperty] private string _dateOfBirthError = "";
|
||||
|
||||
public List<string> GenderOptions { get; } = ["", "M – männlich", "W – weiblich", "D – divers"];
|
||||
public List<string> GenderOptions => GenderAvatarDisplay.Options;
|
||||
public List<string> RelationPresets { get; } = ["Schüler/in", "Mutter", "Vater", "Elternteil", "Erziehungsberechtigte/r", "Sonstige"];
|
||||
|
||||
public ObservableCollection<ContactEntryViewModel> Contacts { get; } = [];
|
||||
@@ -490,13 +680,7 @@ public partial class AddStudentDialogViewModel : ObservableObject
|
||||
FirstName = FirstName.Trim(),
|
||||
LastName = LastName.Trim(),
|
||||
DateOfBirth = dob,
|
||||
Gender = SelectedGender switch
|
||||
{
|
||||
"M – männlich" => Gender.M,
|
||||
"W – weiblich" => Gender.W,
|
||||
"D – divers" => Gender.D,
|
||||
_ => (Gender?)null,
|
||||
},
|
||||
Gender = GenderAvatarDisplay.FromOption(SelectedGender),
|
||||
Notes = string.IsNullOrWhiteSpace(Notes) ? null : Notes.Trim(),
|
||||
Contacts = Contacts.Select(c => c.ToModel()).Where(c => !string.IsNullOrWhiteSpace(c.Name)).ToList(),
|
||||
};
|
||||
@@ -510,6 +694,7 @@ public partial class ContactEntryViewModel : ObservableObject
|
||||
|
||||
[ObservableProperty] private string _name = "";
|
||||
[ObservableProperty] private string _relation = "";
|
||||
[ObservableProperty] private string _letterSalutation = "";
|
||||
[ObservableProperty] private string _phone = "";
|
||||
[ObservableProperty] private string _email = "";
|
||||
[ObservableProperty] private string _street = "";
|
||||
@@ -524,6 +709,7 @@ public partial class ContactEntryViewModel : ObservableObject
|
||||
{
|
||||
Name = Name.Trim(),
|
||||
Relation = Relation.Trim(),
|
||||
LetterSalutation = string.IsNullOrWhiteSpace(LetterSalutation) ? null : LetterSalutation.Trim(),
|
||||
Phone = string.IsNullOrWhiteSpace(Phone) ? null : Phone.Trim(),
|
||||
Email = string.IsNullOrWhiteSpace(Email) ? null : Email.Trim(),
|
||||
Street = string.IsNullOrWhiteSpace(Street) ? null : Street.Trim(),
|
||||
@@ -538,6 +724,7 @@ public partial class ContactEditDialogViewModel : ObservableObject
|
||||
|
||||
[ObservableProperty] private string _name = "";
|
||||
[ObservableProperty] private string _relation = "Elternteil";
|
||||
[ObservableProperty] private string _letterSalutation = "";
|
||||
[ObservableProperty] private string _phone = "";
|
||||
[ObservableProperty] private string _email = "";
|
||||
[ObservableProperty] private string _street = "";
|
||||
@@ -564,6 +751,7 @@ public partial class ContactEditDialogViewModel : ObservableObject
|
||||
if (source is null) return;
|
||||
Name = source.Name;
|
||||
Relation = source.Relation;
|
||||
LetterSalutation = source.LetterSalutation ?? "";
|
||||
Phone = source.Phone ?? "";
|
||||
Email = source.Email ?? "";
|
||||
Street = source.Street ?? "";
|
||||
@@ -614,6 +802,7 @@ public partial class ContactEditDialogViewModel : ObservableObject
|
||||
Id = _source?.Id ?? Guid.NewGuid(),
|
||||
Name = Name.Trim(),
|
||||
Relation = Relation.Trim(),
|
||||
LetterSalutation = NullIfEmpty(LetterSalutation),
|
||||
Phone = NullIfEmpty(Phone),
|
||||
Email = NullIfEmpty(Email),
|
||||
Street = NullIfEmpty(Street),
|
||||
|
||||
Reference in New Issue
Block a user