public void Edit_ValidData_UpdatedTodoItem() { //Arrange var id = TestHelper.TodoItems.ElementAt(1).Id; var data = _todoItemService.GetById(id); //Act var item = new TodoItem() { Id = id, Name = "Updated Todo", Created = data.Created, RowVersion = data.RowVersion }; data = _todoItemService.Edit(id, item); //Assert Assert.Equal(id, data.Id); Assert.Equal("Updated Todo", data.Name); }
public IActionResult Update(Guid id, TodoItem item) { if (!ModelState.IsValid) { return(BadRequest(ModelState.GetErrors())); } try { var updateItem = _todoItemService.Edit(id, item); if (updateItem == null) { return(BadRequest("Item does not exist in list.")); } } catch (DbUpdateConcurrencyException) { return(Conflict("Conflict has been found.")); } return(Ok("Item successfully updated.")); }
public async Task <IActionResult> Edit(TodoItem todoItem) { await _todoItemService.Edit(todoItem, User); return(RedirectToAction("Index")); }