private async void OnTaskStatusChange(object sender) { try { IsSending = true; await _service.Update((TodoItem)sender); await RefreshTodos(); } catch (TodoMashException ex) { _notifier.ShowError(ex.Message); } finally { IsSending = false; } }
// PUT: api/TodoItem/5 public IHttpActionResult Put(int id, [FromBody] TodoItemUpdateViewModel value) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } return(Ok(_service.Update(id, value))); }
public async Task <ActionResult> Edit(int?id, TodoItemDTO todoItemDTO) { if (ModelState.IsValid && id != null) { await todoItemService.Update(id.Value, todoItemDTO); return(RedirectToAction(nameof(Index))); } return(View(todoItemDTO)); }
public IActionResult Update(string id, TodoItem todoItemIn) { var todoItem = _todoItemService.Get(id); if (todoItem == null) { return(NotFound()); } _todoItemService.Update(id, todoItemIn); return(NoContent()); }
public IActionResult PutTodoItems(int listId, int id, [FromBody] TodoItem item) { var todo = _todoItemService.Update(listId, id, item); var dto = new TodoItemDto { Id = todo.Id, Title = todo.Title, Description = todo.Description, DueDate = todo.DueDate, Done = todo.Done }; return(Ok(dto)); }
public async Task Update_Should_CallRepository() { // Arrange var item = new TodoItem(); _repositoryMock .Setup(x => x.Update(item)) .Returns(item); _unitOfWorkMock .Setup(x => x.Save()) .ReturnsAsync(true); // Act var actual = await _service.Update(item); // Assert Assert.True(actual); _repositoryMock.Verify(x => x.Update(item), Times.Once()); _unitOfWorkMock.Verify(x => x.Save(), Times.Once()); }
public async Task <IActionResult> PatchTodoItem([FromBody] TodoItem todoItem) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (todoItem.Id == Guid.Empty) { return(BadRequest()); } var foundItem = await _context.Find(todoItem.Id); if (foundItem == null) { return(NotFound($"Item with ID {todoItem.Id} was not found")); } await _context.Update(todoItem); return(Ok()); }
public Task <ActionResponse> UpdateToDoItem(ToDoItem toDoItem) { var userId = User.FindFirstValue(ClaimTypes.NameIdentifier); return(_todoService.Update(userId, toDoItem)); }