Ejemplo n.º 1
0
        public async Task <IActionResult> UpdateTodoItem(long id, TodoItemDTO todoItemDto)
        {
            if (id != todoItemDto.Id)
            {
                return(BadRequest());
            }

            var exists = _itemsService.TodoItemExists(id);

            if (!exists)
            {
                return(NotFound());
            }

            try
            {
                await _itemsService.UpdateTodoItem(id, todoItemDto);
            }
            catch (DbUpdateConcurrencyException)
            {
                return(NotFound());
            }

            return(NoContent());
        }
        public async Task <IActionResult> UpdateTodoItem(long id, TodoItemDto todoItemDto)
        {
            if (id != todoItemDto.Id)
            {
                return(BadRequest());
            }

            try
            {
                await _todoItemsService.UpdateTodoItem(todoItemDto);
            }
            catch (Exception)
            {
                TodoItemDto itemGet = await _todoItemsService.GetTodoItem(todoItemDto.Id);

                if (itemGet == null)
                {
                    return(NotFound());
                }
            }

            return(NoContent());
        }