Пример #1
0
        public Task Create(Task task)
        {
            var context = new TasksContext();

            context.Tasks.Add(task);
            context.SaveChanges();
            return(task);
        }
Пример #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();
        }
Пример #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();
        }
Пример #4
0
        public IEnumerable <Task> List()
        {
            var context = new TasksContext();

            return(context.Tasks.ToList());
        }
Пример #5
0
        public Task Find(int id)
        {
            var context = new TasksContext();

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