fromEntityPlus static method

Future<OrderOverviewModel?> fromEntityPlus(
  1. String documentID,
  2. OrderOverviewEntity? entity, {
  3. String? appId,
})

Implementation

static Future<OrderOverviewModel?> fromEntityPlus(
    String documentID, OrderOverviewEntity? entity,
    {String? appId}) async {
  if (entity == null) return null;

  ShopModel? shopHolder;
  if (entity.shopId != null) {
    try {
      shopHolder = await shopRepository(appId: appId)!.get(entity.shopId);
    } on Exception catch (e) {
      print('Error whilst trying to initialise shop');
      print('Error whilst retrieving shop with id ${entity.shopId}');
      print('Exception: $e');
    }
  }

  return OrderOverviewModel(
    documentID: documentID,
    appId: entity.appId ?? '',
    description: entity.description,
    shop: shopHolder,
    itemImageBackground: await BackgroundModel.fromEntityPlus(
        entity.itemImageBackground,
        appId: appId),
    itemDetailBackground: await BackgroundModel.fromEntityPlus(
        entity.itemDetailBackground,
        appId: appId),
    conditions: await StorageConditionsModel.fromEntityPlus(entity.conditions,
        appId: appId),
  );
}