public IEnumerable <Task> Get()
 {
     using (var dbContext = new TasksDatabaseContext())
     {
         return(dbContext.Tasks.ToList());
     }
 }
 public void Put(int id, [FromBody] bool done)
 {
     using (var dbContext = new TasksDatabaseContext())
     {
         Task objectToUpdate = dbContext.Tasks.FirstOrDefault(t => t.ID == id);
         objectToUpdate.Done = done;
         dbContext.SaveChanges();
     }
 }
 public void Post([FromBody] string taskTitle)
 {
     using (var dbContext = new TasksDatabaseContext())
     {
         Task objectToAdd = new Task {
             Title = taskTitle
         };
         dbContext.Tasks.Add(objectToAdd);
         dbContext.SaveChanges();
     }
 }
Exemple #4
0
 public AssignmentGroupController(TasksDatabaseContext context)
 {
     _context = context;
 }