MemberAdminWindow: Cleanup deletion of telnr and email addresses
This commit is contained in:
@ -61,7 +61,7 @@ namespace Elwig.Windows {
|
||||
(PhoneNr8TypeInput, PhoneNr8Input, PhoneNr8CommentInput),
|
||||
(PhoneNr9TypeInput, PhoneNr9Input, PhoneNr9CommentInput),
|
||||
];
|
||||
foreach (var input in PhoneNrInputs) input.Item1.ItemsSource = PhoneNrTypes;
|
||||
foreach (var input in PhoneNrInputs) input.Type.ItemsSource = PhoneNrTypes;
|
||||
|
||||
InitializeDelayTimer(SearchInput, SearchInput_TextChanged);
|
||||
SearchInput.TextChanged -= SearchInput_TextChanged;
|
||||
@ -281,7 +281,7 @@ namespace Elwig.Windows {
|
||||
inputs.Address.Text = address;
|
||||
}
|
||||
|
||||
private (string, string, string?)? GetPhoneNrInput(int nr) {
|
||||
private (string Type, string Number, string? Comment)? GetPhoneNrInput(int nr) {
|
||||
var inputs = PhoneNrInputs[nr];
|
||||
var number = inputs.Number.Text;
|
||||
if (string.IsNullOrEmpty(number))
|
||||
@ -656,30 +656,24 @@ namespace Elwig.Windows {
|
||||
}
|
||||
}
|
||||
|
||||
Context.RemoveRange(m.TelephoneNumbers);
|
||||
for (int i = 0, j = 0; i < PhoneNrInputs.Length; i++) {
|
||||
var input = GetPhoneNrInput(i);
|
||||
var phoneNr = m.TelephoneNumbers.FirstOrDefault(p => p.Nr - 1 == i);
|
||||
if (phoneNr != null) {
|
||||
Context.Remove(phoneNr);
|
||||
}
|
||||
if (input != null) {
|
||||
var pInput = input.Value;
|
||||
MemberTelNr p = Context.CreateProxy<MemberTelNr>();
|
||||
p.MgNr = newMgNr;
|
||||
p.Nr = ++j;
|
||||
p.Type = pInput.Item1;
|
||||
p.Number = pInput.Item2;
|
||||
p.Comment = pInput.Item3;
|
||||
p.Type = pInput.Type;
|
||||
p.Number = pInput.Number;
|
||||
p.Comment = pInput.Comment;
|
||||
await Context.AddAsync(p);
|
||||
}
|
||||
}
|
||||
|
||||
Context.RemoveRange(m.EmailAddresses);
|
||||
for (int i = 0, j = 0; i < EmailAddressInputs.Length; i++) {
|
||||
var input = GetEmailAddressInput(i);
|
||||
var emailAddr = m.EmailAddresses.FirstOrDefault(a => a.Nr - 1 == i);
|
||||
if (emailAddr != null) {
|
||||
Context.Remove(emailAddr);
|
||||
}
|
||||
if (input != null && input != "") {
|
||||
MemberEmailAddr a = Context.CreateProxy<MemberEmailAddr>();
|
||||
a.MgNr = newMgNr;
|
||||
|
Reference in New Issue
Block a user