save method
Implementation
Future<bool> save() async {
final bool isNew = editing == null;
String? t(TextEditingController c) => isNew ? c.text.trim().nullIfEmpty() : c.text.trim();
final UHotelUpdateParams p = UHotelUpdateParams(
id: editing?.id ?? "",
tags: tags,
title: titleController.text.trim(),
cityCode: cityCode,
stars: intOf(starsController),
address: t(addressController),
phoneNumber: phoneController.text.nullIfEmpty(),
email: emailController.text.nullIfEmpty(),
description: t(descriptionController),
policies: t(policiesController),
checkInTime: t(checkInTimeController),
checkOutTime: t(checkOutTimeController),
rules: splitList(rulesController.text),
latitude: numOf(latitudeController),
longitude: numOf(longitudeController),
cancellationFreeHours: intOf(cancellationFreeHoursController),
cancellationPenaltyNights: intOf(cancellationPenaltyNightsController),
adminUserIds: admins.map((UUserResponse u) => u.id).toList(),
highlights: highlights,
website: t(websiteController),
whatsapp: t(whatsappController),
instagram: t(instagramController),
telegram: t(telegramController),
howToGetThere: t(howToGetThereController),
nearby: nearby,
faqs: faqs,
);
final Object? ok = await send(
isNew ? UServices.hotel.createHotel(p: UHotelCreateParams.fromMap(p.toMap()..remove("id"))) : UServices.hotel.updateHotel(p: p),
() {},
);
if (ok == null) return false;
await UServices.media.syncGallery(photos, existing: media, hotelId: editing?.id ?? (ok as UResponse<String>).result);
unawaited(read());
return true;
}