Пример #1
0
        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);
        }
Пример #2
0
        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."));
        }
Пример #3
0
        public async Task <IActionResult> Edit(TodoItem todoItem)
        {
            await _todoItemService.Edit(todoItem, User);

            return(RedirectToAction("Index"));
        }