public JsonResult WeightEntry(WeightEntryModel model)
        {
            if (ModelState.IsValid)
            {
                using (var context = new DietJournalEntities())
                {
                    WeightEntry weightEntry = null;
                    if (model.Id > 0)
                    {
                        weightEntry = context.WeightEntries.FirstOrDefault(e => e.Id == model.Id);
                    }

                    if (weightEntry == null)
                    {
                        weightEntry = context.WeightEntries.CreateObject();
                        context.WeightEntries.AddObject(weightEntry);
                    }

                    weightEntry.Amount = model.Amount;
                    weightEntry.EntryDate = model.ConsumedDate;
                    weightEntry.SavedDate = DateTime.Now;
                    weightEntry.UserId = CurrentUserId.Value;

                    context.SaveChanges();
                }

                return Json(new { IsValid = true, ReturnUrl = Url.Action("Index", new { date = model.ConsumedDate }) });
            }

            return Json(new { IsValid = false, ErrorMessage = "" });
        }
 public ActionResult WeightEntry(DateTime date)
 {
     var model = new WeightEntryModel { ConsumedDate = date };
     return View(model);
 }