/// <summary> /// Creates new instance of meal. /// </summary> /// <param name="meal"></param> /// <returns></returns> public static Meal ToMeal(this IEnumerable<DishModel> meal) { double carbAmount =0; if(meal != null) { foreach (var dish in meal) { if (dish.NutritionFacts != null) carbAmount = carbAmount + dish.NutritionFacts.TotalCarbohydrate; } } List<Portion> portions = new List<Portion>(); string restaurantId = string.Empty; foreach (var dish in meal) { Portion portion = new Portion(); portion.CarbAmount = dish.NutritionFacts.TotalCarbohydrate; portion.PrtionFrom = dish.ToDish(); portions.Add(portion); restaurantId = dish.RestaurantId; } Meal returnValue = new Meal() { CreatedAt = DateTime.UtcNow, Id = Guid.NewGuid(), CarbAmount = carbAmount, //Currently can be taken from the history of the locations in suggest option. //MealLocation //Very important to care this value. //Suspicious Portions = portions, RestaurantId = restaurantId, }; return returnValue; }
public static Portion ToPortion(this PortionModel portionModel) { Portion returnValue = new Portion() { PrtionFrom = portionModel.PortionFrom.ToDish(), PortionAmount = portionModel.PortionAmount }; return returnValue; }