public async Task <TodoItem> Create(TodoItem todoItem) { _context.TodoItems.Add(todoItem); await _context.SaveChangesAsync(); return(todoItem); }
public async Task <IActionResult> PutTodoItem(int id, TodoItem todoItem) { if (id != todoItem.Id) { return(BadRequest()); } _context.Entry(todoItem).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TodoItemExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <BllTodoItem> Add(BllTodoItem item) { if (item == null) { throw new ArgumentNullException(nameof(item)); } var result = db.TodoItems.Add(item); await db.SaveChangesAsync(); return(result); }