示例#1
0
 public ActionResult Create(ToDoList todolist)
 {
     if (ModelState.IsValid) {
         todolistRepository.InsertOrUpdate(todolist);
         todolistRepository.Save();
         return RedirectToAction("Index");
     } else {
         return View();
     }
 }
示例#2
0
 public void InsertOrUpdate(ToDoList todolist)
 {
     if (todolist.Id == default(int)) {
         // New entity
         context.ToDoLists.Add(todolist);
     } else {
         // Existing entity
         context.ToDoLists.Attach(todolist);
         context.Entry(todolist).State = EntityState.Modified;
     }
 }
示例#3
0
 public void InsertOrUpdate(ToDoList todolist)
 {
     if (todolist.Id == default(int))
     {
         // New entity
         context.ToDoLists.Add(todolist);
     }
     else
     {
         // Existing entity
         context.ToDoLists.Attach(todolist);
         context.Entry(todolist).State = EntityState.Modified;
     }
 }