updateArticleRetailFromForm method
Future
updateArticleRetailFromForm(
)
inherited
Implementation
Future<ArticleRetail> updateArticleRetailFromForm() async {
final now = DateTime.now();
ArticleRetail newArticleRetail = _articleRetail.copyWith(
fullName: name.trim(),
price: num.parse(price.trim()),
barcodeEAN: barcodeEAN.trim(),
updateDate: now,
);
if (photoPath.isNotEmpty) {
final newPhoto = ArticlePhoto(
calibreId: newArticleRetail.calibreId,
id: newArticleRetail.id,
path: photoPath,
source: PhotoSource.file);
await _articlesStore.upsertPhoto(newPhoto);
}
if ((cost.isNotEmpty)) {
newArticleRetail =
newArticleRetail.copyWith(cost: num.parse(cost.trim()));
}
if ((unitsPerPiece.isNotEmpty)) {
newArticleRetail =
newArticleRetail.copyWith(weight: double.parse(unitsPerPiece.trim()));
}
if (int.tryParse(barcodeEAN.trim()) != null) {
newArticleRetail =
newArticleRetail.copyWith(barcodeEAN: barcodeEAN.trim());
}
final articleRetailUpdated =
await _articlesStore.updateArticle<ArticleRetail>(newArticleRetail);
return articleRetailUpdated;
}