Example #1
0
        public Task Create(Task task)
        {
            var context = new TasksContext();

            context.Tasks.Add(task);
            context.SaveChanges();
            return(task);
        }
Example #2
0
        public void Update(int id, Task task)
        {
            var context = new TasksContext();
            var dbTask  = context.Tasks.First(x => x.Id == id);

            dbTask.Name = task.Name;
            context.SaveChanges();
        }
Example #3
0
        public void Delete(int id)
        {
            var context = new TasksContext();
            var task    = context.Tasks.First(x => x.Id == id);

            context.Tasks.Remove(task);
            context.SaveChanges();
        }
Example #4
0
        public IEnumerable <Task> List()
        {
            var context = new TasksContext();

            return(context.Tasks.ToList());
        }
Example #5
0
        public Task Find(int id)
        {
            var context = new TasksContext();

            return(context.Tasks.FirstOrDefault(x => x.Id == id));
        }