public JsonResult RecordCalorieCountOffDay(string personId, string currentDateTime) { DateTime localTime = DateTime.Parse(currentDateTime); CalorieCountHandler handler = new CalorieCountHandler(); handler.InsertCalorieCountOffDay(Convert.ToInt32(personId), localTime); return(Json("Off day recorded")); }
public JsonResult GetCaloriesForLastThirtyDays(string personId, string currentDateTime) { DateTime endDate = DateTime.Parse(currentDateTime); DateTime startDate = endDate.AddDays(-30); CalorieCountHandler handler = new CalorieCountHandler(); List <XYModel> calorieAndDateModel = handler.GetCaloriesAndDatesAsXAndY(Convert.ToInt32(personId), startDate, endDate); return(Json(calorieAndDateModel)); }
public JsonResult RecordCalories(string personId, string calorieValue, string currentDateTime) { DateTime localTime = DateTime.Parse(currentDateTime); CalorieCountHandler handler = new CalorieCountHandler(); List <CalorieCount> counts = handler.Insert(Convert.ToInt32(personId), Convert.ToInt32(calorieValue), localTime); int total = counts.Select(x => x.Calories).Sum(); return(Json("Total Calories " + total)); }