productToProductModel function

Future<ProductModel> productToProductModel(
  1. String uniqueId,
  2. ShopModel shop,
  3. AppModel app,
  4. String memberId,
  5. Product product,
)

Implementation

Future<ProductModel> productToProductModel(String uniqueId, ShopModel shop,
    AppModel app, String memberId, Product product) async {
  var productImages = <ProductImageModel>[];
  if (product.assetLocation1 != null) {
    productImages.add(ProductImageModel(
        documentID: constructDocumentId(
            uniqueId: uniqueId, documentId: product.imageId1()),
        image:
            await uploadPlatformPhoto(app, memberId, product.assetLocation1!)));
  }
  if (product.assetLocation2 != null) {
    productImages.add(ProductImageModel(
        documentID: constructDocumentId(
            uniqueId: uniqueId, documentId: product.imageId1()),
        image:
            await uploadPlatformPhoto(app, memberId, product.assetLocation2!)));
  }
  if (product.assetLocation3 != null) {
    productImages.add(ProductImageModel(
        documentID: constructDocumentId(
            uniqueId: uniqueId, documentId: product.imageId1()),
        image:
            await uploadPlatformPhoto(app, memberId, product.assetLocation3!)));
  }
  if (product.assetLocation4 != null) {
    productImages.add(ProductImageModel(
        documentID: constructDocumentId(
            uniqueId: uniqueId, documentId: product.imageId1()),
        image:
            await uploadPlatformPhoto(app, memberId, product.assetLocation4!)));
  }
  return ProductModel(
    documentID:
        constructDocumentId(uniqueId: uniqueId, documentId: product.id!),
    appId: app.documentID,
    title: product.title,
    about: product.about,
    shop: shop,
    images: productImages,
    price: product.price,
    weight: 100,
    posSize: screen75(app.documentID),
/*
    conditions: StorageConditionsModel(
        privilegeLevelRequired:
            PrivilegeLevelRequiredSimple.noPrivilegeRequiredSimple),
*/
  );
}