fromEntity static method

Future<OrderModel?> fromEntity(
  1. String documentID,
  2. OrderEntity? entity
)

Implementation

static Future<OrderModel?> fromEntity(
    String documentID, OrderEntity? entity) async {
  if (entity == null) return null;
  var counter = 0;
  return OrderModel(
    documentID: documentID,
    appId: entity.appId ?? '',
    name: entity.name,
    email: entity.email,
    shipStreet1: entity.shipStreet1,
    shipStreet2: entity.shipStreet2,
    shipCity: entity.shipCity,
    shipState: entity.shipState,
    postcode: entity.postcode,
    country: entity.country,
    invoiceSame: entity.invoiceSame,
    invoiceStreet1: entity.invoiceStreet1,
    invoiceStreet2: entity.invoiceStreet2,
    invoiceCity: entity.invoiceCity,
    invoiceState: entity.invoiceState,
    invoicePostcode: entity.invoicePostcode,
    invoiceCountry: entity.invoiceCountry,
    products: entity.products == null
        ? null
        : List<OrderItemModel>.from(
            await Future.wait(entity.products!.map((item) {
            counter++;
            return OrderItemModel.fromEntity(counter.toString(), item);
          }).toList())),
    totalPrice: entity.totalPrice,
    currency: entity.currency,
    paymentReference: entity.paymentReference,
    shipmentReference: entity.shipmentReference,
    deliveryReference: entity.deliveryReference,
    paymentNote: entity.paymentNote,
    shipmentNote: entity.shipmentNote,
    deliveryNote: entity.deliveryNote,
    status: toOrderStatus(entity.status),
    timeStamp: entity.timeStamp,
  );
}