updateOrganization method
Future<void>
updateOrganization(
- String orgId, {
- List<ContactInput>? contacts,
- List<AddressInput>? addresses,
- Key? orgKey,
})
Implementation
Future<void> updateOrganization(
String orgId, {
List<ContactInput>? contacts,
List<AddressInput>? addresses,
Key? orgKey,
}) async {
emit(state.startLoading(updateOrgLoading));
try {
await provider.updateOrg(
orgId: orgId,
orgKey: orgKey,
contacts: contacts,
addresses: addresses,
);
emit(state.copyWith(
selectedOrgData: state.selectedOrgData?.copyWith(
publicKey: orgKey?.publicKey,
contacts: contacts
?.map((c) => Contact(
type: c.type,
description: c.description,
emailAddress: c.emailAddress,
phoneNumber: c.phoneNumber,
))
.toList(),
addresses: addresses
?.map((c) => Address(
type: c.type,
description: c.description,
number: c.number,
street: c.street,
other: c.other,
municipality: c.municipality,
county: c.county,
province: c.province,
postalCode: c.postalCode,
countryCode: c.countryCode,
))
.toList(),
),
));
} on OrgServiceError catch (_) {
emit(
state.addMessage(
Message.error(
_localizations.updateOrgError,
),
),
);
} catch (e) {
_logger.severe('Error updating organization: $e');
emit(
state.addMessage(Message.error(
_localizations.unknownError,
)),
);
} finally {
emit(state.endLoading(updateOrgLoading));
}
}