/// <summary> /// Add aliment to the dish then change the name of the recipe /// </summary> public void AddAliment(Aliment _aliment) { bool hasFound; // Add new aliment Aliment newAliment = new Aliment(); newAliment = _aliment; listAliments.Add(newAliment); // Find the recipe nameDish = FoodDatabase.GetDishRecipes(listAliments, out hasFound); if (hasFound) { //GetComponent<MeshRenderer>().materials = ; //GetComponent<MeshFilter>().mesh = ; } // Destroy the old aliment that is now in the dish if (_aliment.gameObject != null) { Destroy(_aliment.gameObject); } }
private void CreatePool(AlimentObject aliment, AlimentState _state) { //create pool GameObject go = new GameObject("Pool :" + aliment.name + " " + _state.ToString()); go.transform.parent = transform; Pool newPool = go.AddComponent <Pool>(); KeyValuePair <string, AlimentState> key = new KeyValuePair <string, AlimentState>(aliment.name, _state); // Create a new key with the NAME and the STATE of the current aliment GameObject tmpAliment = FoodDatabase.InstantiateAliment(aliment, _state); newPool.Init(tmpAliment, DefaultSizePool); pools[key] = newPool; }
private void FillFoodDatabase() { FoodDatabase.Add(new FoodItem { Name = "Waffles", Quantity = 1, CaloriePerItem = 101, Protein = 2, Fat = 3, Carbs = 1 }); FoodDatabase.Add(new FoodItem { Name = "Apples", Quantity = 1, CaloriePerItem = 90, Protein = 2, Fat = 3, Carbs = 1 }); FoodDatabase.Add(new FoodItem { Name = "Eggs", Quantity = 1, CaloriePerItem = 60, Protein = 2, Fat = 3, Carbs = 1 }); FoodDatabase.Add(new FoodItem { Name = "Pasta", Quantity = 1, CaloriePerItem = 250, Protein = 2, Fat = 3, Carbs = 1 }); FoodDatabase.Add(new FoodItem { Name = "Coffee", Quantity = 1, CaloriePerItem = 44, Protein = 2, Fat = 3, Carbs = 1 }); FoodDatabase.Add(new FoodItem { Name = "BLT Sandwich", Quantity = 1, CaloriePerItem = 300, Protein = 2, Fat = 3, Carbs = 1 }); FoodDatabase.Add(new FoodItem { Name = "Chili", Quantity = 1, CaloriePerItem = 444, Protein = 2, Fat = 3, Carbs = 1 }); FoodDatabase.Add(new FoodItem { Name = "Ice cream", Quantity = 1, CaloriePerItem = 300, Protein = 2, Fat = 3, Carbs = 1 }); FoodDatabase.Add(new FoodItem { Name = "Sushi", Quantity = 1, CaloriePerItem = 222, Protein = 2, Fat = 3, Carbs = 1 }); FoodDatabase.Add(new FoodItem { Name = "Carrots", Quantity = 1, CaloriePerItem = 6, Protein = 2, Fat = 3, Carbs = 1 }); FoodDatabase.Add(new FoodItem { Name = "Bananas", Quantity = 1, CaloriePerItem = 77, Protein = 2, Fat = 3, Carbs = 1 }); FoodDatabase.Add(new FoodItem { Name = "Toast", Quantity = 1, CaloriePerItem = 101, Protein = 2, Fat = 3, Carbs = 1 }); FoodDatabase.Add(new FoodItem { Name = "Cereal", Quantity = 1, CaloriePerItem = 194, Protein = 2, Fat = 3, Carbs = 1 }); }
public PartialViewResult FoodDBDetail(int?id) { if (id.HasValue) { FoodDatabase foodDBDetail = FoodAndSportDBService.GetFoodDataById(id); FoodRecord foodRecord = new FoodRecord(); foodRecord.FoodName = foodDBDetail.FoodName; foodRecord.Calories = foodDBDetail.Calories; foodRecord.Food_Id = foodDBDetail.Food_Id; DateTime date = (DateTime)Session["currentDate"]; foodRecord.CreateDate = date; System.Diagnostics.Debug.WriteLine(foodRecord.CreateDate); return(PartialView(foodRecord)); } else { return(PartialView()); } }
public void Insert(FoodRecord newFoodRecord) { /* * var query = from p in db.FoodDatabase * where ((p.FoodName) == newFoodRecord.FoodName) * select p; */ var query = from p in db.FoodDatabase where ((p.Food_Id) == newFoodRecord.Food_Id) select p; //choice from foodDB FoodDatabase foodDatabase = query.Single(); newFoodRecord.Calories = foodDatabase.Calories; newFoodRecord.FoodName = foodDatabase.FoodName; db.FoodRecord.Add(newFoodRecord); Save(); //use stored procedure to calculate calories spent by date db.TotalCaloriesCal(newFoodRecord.CreateDate, newFoodRecord.Username); }