// PUT: api/FoodLogApi/5 public void Put(int id, [FromBody] FoodLogEntry value) { var item = foodDb.Get(id); if (null == item) { foodDb.Create(value); } foodDb.Update(value); }
public ActionResult Edit([Bind(Include = "Id,Quantity,Description,MealTime,Tags,Calories,ProteinInGrams,FatInGrams,CarbohydratesInGrams,SodiumInGrams")] FoodLogEntry foodLogEntry) { if (ModelState.IsValid) { repository.Update(foodLogEntry); Trace.TraceInformation("Updated Nutrition {0}", foodLogEntry.Description); // Application Insights - Track Events Utilities.TelemetryClientHelper.TrackEvent("Updated Nutrition"); return(RedirectToAction("Index")); } return(View(foodLogEntry)); }
public ActionResult Edit(FoodLogEntry foodLogEntry) //public ActionResult Edit([Bind(Include = "Id,Quantity,Description,MealTime,Tags,Calories,ProteinInGrams,FatInGrams,CarbohydratesInGrams,SodiumInGrams,Color")] FoodLogEntry foodLogEntry) { if (ModelState.IsValid) { repository.Update(foodLogEntry); //if (!string.IsNullOrEmpty(foodLogEntry.Color)) //{ // var telemetry = new TelemetryClient(); // telemetry.TrackEvent("Modified food with color field " + foodLogEntry.Id.ToString() + " Color: " + foodLogEntry.Color + " Description:" + foodLogEntry.Description); //} return(RedirectToAction("Index")); } return(View(foodLogEntry)); }