forked from eatvio/eatvio_app
feat(diary): diet
This commit is contained in:
@@ -102,15 +102,73 @@ class DiaryCubit extends Cubit<DiaryState> {
|
||||
required String portion,
|
||||
required int quantity,
|
||||
int? productNutritionalValueId,
|
||||
required PortionState portionState,
|
||||
}) async {
|
||||
await diaryRepository.updateProductInMeal(
|
||||
if (portionState == PortionState.filled_diet || portionState == PortionState.eaten_from_diet) {
|
||||
// await diaryRepository.deleteProductFromMeal(
|
||||
// diaryId: diaryId,
|
||||
// mealId: mealId,
|
||||
// portionId: portionId,
|
||||
// );
|
||||
// todo delete product from diet
|
||||
await diaryRepository.addPortionToMeal(
|
||||
diaryId: diaryId,
|
||||
mealId: mealId,
|
||||
productName: productName,
|
||||
portion: portion,
|
||||
quantity: quantity,
|
||||
productNutritionalValueId: productNutritionalValueId,
|
||||
);
|
||||
} else {
|
||||
await diaryRepository.updateProductInMeal(
|
||||
diaryId: diaryId,
|
||||
mealId: mealId,
|
||||
portionId: portionId,
|
||||
productName: productName,
|
||||
portion: portion,
|
||||
quantity: quantity,
|
||||
productNutritionalValueId: productNutritionalValueId,
|
||||
portionState: portionState,
|
||||
);
|
||||
}
|
||||
await fetchDiary();
|
||||
}
|
||||
|
||||
markEaten({
|
||||
required int diaryId,
|
||||
required int mealId,
|
||||
required int portionId,
|
||||
}) async {
|
||||
await diaryRepository.markEaten(
|
||||
diaryId: diaryId,
|
||||
mealId: mealId,
|
||||
portionId: portionId,
|
||||
);
|
||||
await fetchDiary();
|
||||
}
|
||||
|
||||
unmarkEaten({
|
||||
required int diaryId,
|
||||
required int mealId,
|
||||
required int portionId,
|
||||
}) async {
|
||||
await diaryRepository.unmarkEaten(
|
||||
diaryId: diaryId,
|
||||
mealId: mealId,
|
||||
portionId: portionId,
|
||||
);
|
||||
await fetchDiary();
|
||||
}
|
||||
|
||||
restore({
|
||||
required int diaryId,
|
||||
required int mealId,
|
||||
required int portionId,
|
||||
}) async {
|
||||
await diaryRepository.restore(
|
||||
diaryId: diaryId,
|
||||
mealId: mealId,
|
||||
portionId: portionId,
|
||||
productName: productName,
|
||||
portion: portion,
|
||||
quantity: quantity,
|
||||
productNutritionalValueId: productNutritionalValueId,
|
||||
);
|
||||
await fetchDiary();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user