MemberAdminWindow: Fix crash when editing telnr or email
This commit is contained in:
@ -659,44 +659,34 @@ namespace Elwig.Windows {
|
||||
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 (input == null) {
|
||||
if (phoneNr != null) {
|
||||
Context.Remove(phoneNr);
|
||||
}
|
||||
} else {
|
||||
if (phoneNr != null) {
|
||||
Context.Remove(phoneNr);
|
||||
}
|
||||
if (input != null) {
|
||||
var pInput = input.Value;
|
||||
MemberTelNr p = phoneNr ?? Context.CreateProxy<MemberTelNr>();
|
||||
MemberTelNr p = Context.CreateProxy<MemberTelNr>();
|
||||
p.MgNr = newMgNr;
|
||||
p.Nr = ++j;
|
||||
p.Type = pInput.Item1;
|
||||
p.Number = pInput.Item2;
|
||||
p.Comment = pInput.Item3;
|
||||
if (phoneNr == null) {
|
||||
p.MgNr = newMgNr;
|
||||
await Context.AddAsync(p);
|
||||
} else {
|
||||
Context.Update(p);
|
||||
}
|
||||
await Context.AddAsync(p);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < EmailAddressInputs.Length; i++) {
|
||||
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 (input == null || input == "") {
|
||||
if (emailAddr != null) {
|
||||
Context.Remove(emailAddr);
|
||||
}
|
||||
} else {
|
||||
MemberEmailAddr a = emailAddr ?? Context.CreateProxy<MemberEmailAddr>();
|
||||
a.Nr = i + 1;
|
||||
a.Address = input ?? "";
|
||||
if (emailAddr != null) {
|
||||
Context.Remove(emailAddr);
|
||||
}
|
||||
if (input != null && input != "") {
|
||||
MemberEmailAddr a = Context.CreateProxy<MemberEmailAddr>();
|
||||
a.MgNr = newMgNr;
|
||||
a.Nr = ++j;
|
||||
a.Address = input;
|
||||
a.Comment = null;
|
||||
if (emailAddr == null) {
|
||||
a.MgNr = newMgNr;
|
||||
await Context.AddAsync(a);
|
||||
} else {
|
||||
Context.Update(a);
|
||||
}
|
||||
await Context.AddAsync(a);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user