Пример #1
0
 public IEnumerable <ToDoListModel> Read()
 {
     using (var db = new ToDoListDbContext())
     {
         return(db.ToDoTasks.AsNoTracking().ToList());
     }
 }
Пример #2
0
 public void Update(ToDoListModel model)
 {
     using (var db = new ToDoListDbContext())
     {
         db.Entry(model).State = EntityState.Modified;
         db.SaveChanges();
     }
 }
Пример #3
0
 public void Add(ToDoListModel model)
 {
     using (var db = new ToDoListDbContext())
     {
         db.ToDoTasks.Add(model);
         db.SaveChanges();
     }
 }
Пример #4
0
 public void Delete(ToDoListModel model)
 {
     using (var db = new ToDoListDbContext())
     {
         var entry = db.Entry(model);
         if (entry.State == EntityState.Detached)
         {
             db.ToDoTasks.Attach(model);
         }
         db.ToDoTasks.Remove(model);
         db.SaveChanges();
     }
 }