public Task[] RetriveTasks() { using (var db = new TasksContext()) { return(db.Tasks.ToArray()); } }
public Task RetriveTask(int id) { using (var db = new TasksContext()) { return(db.Tasks.FirstOrDefault(s => s.Id == id)); } }
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(); } }
public Task AddTask(Task task) { using (var db = new TasksContext()) { var result = db.Tasks.Add(task); db.SaveChanges(); return(result); } }
public Task UpdateTask(Task task) { using (var db = new TasksContext()) { db.Entry(task).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(task); } }