public ActionResult Edit(Guid id, Todo model)
        {
            if (ModelState.IsValid)
            {
                this.DataContext.Todos.Single(x => x.TodoId == id);
                this.DataContext.Todos.ApplyCurrentValues(model);
                return RedirectToAction("Index");
            }

            ViewBag.Contexts =
                this.DataContext.Contexts.ToList().Select(
                    x => new SelectListItem { Selected = x.ContextId == model.ContextId, Text = x.Name, Value = x.ContextId.ToString() })
                    .ToList();

            return this.View(model);
        }
        public ActionResult Create(Todo model)
        {
            if (ModelState.IsValid)
            {
                model.TodoId = Guid.NewGuid();
                this.DataContext.Todos.AddObject(model);
                return RedirectToAction("Index");
            }

            ViewBag.Contexts =
                this.DataContext.Contexts.ToList().Select(
                    x => new SelectListItem { Selected = x.ContextId == model.ContextId, Text = x.Name, Value = x.ContextId.ToString() })
                    .ToList();

            return View();
        }
 /// <summary>
 /// Create a new Todo object.
 /// </summary>
 /// <param name="todoId">Initial value of the TodoId property.</param>
 /// <param name="contextId">Initial value of the ContextId property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="isDone">Initial value of the IsDone property.</param>
 public static Todo CreateTodo(global::System.Guid todoId, global::System.Guid contextId, global::System.String name, global::System.Boolean isDone)
 {
     Todo todo = new Todo();
     todo.TodoId = todoId;
     todo.ContextId = contextId;
     todo.Name = name;
     todo.IsDone = isDone;
     return todo;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the Todos EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToTodos(Todo todo)
 {
     base.AddObject("Todos", todo);
 }