Esempio n. 1
0
 public Task[] RetriveTasks()
 {
     using (var db = new TasksContext())
     {
         return(db.Tasks.ToArray());
     }
 }
Esempio n. 2
0
 public Task RetriveTask(int id)
 {
     using (var db = new TasksContext())
     {
         return(db.Tasks.FirstOrDefault(s => s.Id == id));
     }
 }
Esempio n. 3
0
 public void DeleteTask(int id)
 {
     using (var db = new TasksContext())
     {
         db.Entry(db.Tasks.FirstOrDefault(s => s.Id == id)).State = System.Data.Entity.EntityState.Deleted;
         db.SaveChanges();
     }
 }
Esempio n. 4
0
 public Task AddTask(Task task)
 {
     using (var db = new TasksContext())
     {
         var result = db.Tasks.Add(task);
         db.SaveChanges();
         return(result);
     }
 }
Esempio n. 5
0
 public Task UpdateTask(Task task)
 {
     using (var db = new TasksContext())
     {
         db.Entry(task).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
         return(task);
     }
 }