private IEnumerable <IFoodstuff> GetSaladIngredients(double weight, DishesIndex dish) { Console.Write($"{dish} будет готов через секунду: "); for (int i = 1; i < 2; i++) { Thread.Sleep(1000); Console.Write($"{i} "); } Console.Write($"\n"); var saladWeight = ProductCalculator.CalculateWeightOfProductInDish( weight, SaladData.GRAMS_OF_SALAD_PER_100_GRAMS_OF_SALAD); var parmesanWeight = ProductCalculator.CalculateWeightOfProductInDish( weight, SaladData.GRAMS_OF_PARMESAN_PER_100_GRAMS_OF_SALAD); var breadWeight = ProductCalculator.CalculateWeightOfProductInDish( weight, SaladData.GRAMS_OF_BREAD_PER_100_GRAMS_OF_SALAD); var garlicWeight = ProductCalculator.CalculateWeightOfProductInDish( weight, SaladData.GRAMS_OF_GARLIC_PER_100_GRAMS_OF_SALAD); var oliveOilWeight = ProductCalculator.CalculateWeightOfProductInDish( weight, SaladData.GRAMS_OF_OLIVE_OIL_PER_100_GRAMS_OF_SALAD); var saltWeight = ProductCalculator.CalculateWeightOfProductInDish( weight, SaladData.GRAMS_OF_SALT_PER_100_GRAMS_OF_SALAD); var blackPepperWeight = ProductCalculator.CalculateWeightOfProductInDish( weight, SaladData.GRAMS_OF_BLACK_PEPPER_PER_100_GRAMS_OF_SALAD); return(new List <IFoodstuff> { Store.GetLactucaSativa(saladWeight), Store.GetParmesan(parmesanWeight), Store.GetCiabattaBread(breadWeight), Store.GetGarlic(garlicWeight), Store.GetOliveOil(oliveOilWeight), Store.GetSeaSalt(saltWeight), Store.GetBlackPepper(blackPepperWeight) }); }
private IEnumerable <IFoodstuff> GetSauceIngredients(double weight, DishesIndex dish) { Console.Write($"{dish} будет готов через секунду: "); for (int i = 1; i < 2; i++) { Thread.Sleep(1000); Console.Write($"{i} "); } Console.Write($"\n"); var eggYolkWeight = ProductCalculator.CalculateWeightOfProductInDish( weight, SauceData.GRAMS_OF_EGG_YOLK_PER_100_GRAMS_OF_SAUCE); var powderWeight = ProductCalculator.CalculateWeightOfProductInDish( weight, SauceData.GRAMS_OF_MUSTARD_POWDER_PER_100_GRAMS_OF_SAUCE); var kefirWeight = ProductCalculator.CalculateWeightOfProductInDish( weight, SauceData.GRAMS_OF_KEFIR_PER_100_GRAMS_OF_SAUCE); var oliveOilWeight = ProductCalculator.CalculateWeightOfProductInDish( weight, SauceData.GRAMS_OF_OLIVE_OIL_PER_100_GRAMS_OF_SAUCE); var saltWeight = ProductCalculator.CalculateWeightOfProductInDish( weight, SauceData.GRAMS_OF_SALT_PER_100_GRAMS_OF_SAUCE); var oreganoWeight = ProductCalculator.CalculateWeightOfProductInDish( weight, SauceData.GRAMS_OF_OREGANO_PER_100_GRAMS_OF_SAUCE); return(new List <IFoodstuff> { Store.GetEggYolk(eggYolkWeight), Store.GetMustardPowder(powderWeight), Store.GetKefir(kefirWeight), Store.GetOliveOil(oliveOilWeight), Store.GetSeaSalt(saltWeight), Store.GetOregano(oreganoWeight) }); }
public IFoodstuff MakeDishBy(IChef chef, DishesIndex dish, double weight) { try { var sauceWeight = ProductCalculator.CalculateWeightOfProductInDish( weight, SaladData.GRAMS_OF_CAESAR_SAUCE_PER_100_GRAMS_OF_SALAD); var saladDressing = chef.MakeDish(DishesIndex.CaesarSauce, sauceWeight); return(chef.MakeDish(dish, weight, saladDressing)); } catch { throw; } }
protected virtual Dictionary <string, double> CalculateNutritionInformation(Dictionary <IFoodstuff, double> _proportions) { var query = _proportions .Select(proportion => { var caloric = ProductCalculator.CalculateWeightOfProductInDish( proportion.Value, proportion.Key.CaloricPer100Grams); var fats = ProductCalculator.CalculateWeightOfProductInDish( proportion.Value, proportion.Key.FatsPer100Grams); var proteins = ProductCalculator.CalculateWeightOfProductInDish( proportion.Value, proportion.Key.ProteinsPer100Grams); var carbohydrates = ProductCalculator.CalculateWeightOfProductInDish( proportion.Value, proportion.Key.CarbohydratesPer100Grams); var r = new { caloric, fats, proteins, carbohydrates }; return(r); }) .Aggregate((f, n) => { return (new { caloric = f.caloric + n.caloric, fats = f.fats + n.fats, proteins = f.proteins + n.proteins, carbohydrates = f.carbohydrates + n.carbohydrates }); }) ; return(new Dictionary <string, double> { { "caloric", query.caloric }, { "fats", query.fats }, { "proteins", query.proteins }, { "carbohydrates", query.carbohydrates } }); }