public async Task <IActionResult> PutToDoUsers(int id, ToDoUsers toDoUsers) { if (id != toDoUsers.user_Id) { return(BadRequest()); } _context.Entry(toDoUsers).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ToDoUsersExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task CreateTodoAsync(ToDoItem newItem) { newItem.Id = Guid.NewGuid().ToString(); await _dbContext.AddAsync(newItem); await _dbContext.SaveChangesAsync(); }
public async Task <IActionResult> Create(ToDoList list) { _context.ToDoLists.Add(list); await _context.SaveChangesAsync(); return(CreatedAtRoute("GetList", new { id = list.ID }, list)); }
public async Task <IActionResult> Update(int id, ToDoItem item) { var td = _context.ToDoItems.Find(id); if (td == null) { return(NotFound()); } td.Completed = item.Completed; td.Name = item.Name; td.ListID = td.ListID; _context.ToDoItems.Update(td); await _context.SaveChangesAsync(); return(NoContent()); }
public async Task <IActionResult> PutToDoItems(int id, ToDoItems toDoItems) { toDoItems.Atividade_Id = id; _context.Entry(toDoItems).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ToDoItemsExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }