public ActionResult Create(Todo todo) { if (ModelState.IsValid) { Db.Store(todo); return Json(new { ok = true, todo }); } return Json(new { ok = false }); }
public ActionResult Update(Todo input) { if (input == null || input.Id.IsEmpty()) return Json(new { ok = false }); var todo = Db.Load<Todo>(input.Id); if (todo != null) { todo.IsCompleted = input.IsCompleted; todo.Text = input.Text; } return Json(new { ok = true }); }