Exemplo n.º 1
0
        public static ImmutableArray<Todo> CompleteTodoReducer(ImmutableArray<Todo> previousState, CompleteTodoAction action)
        {
            var todoToEdit = previousState.First(todo => todo.Id == action.TodoId);

            return previousState
                .Replace(todoToEdit, new Todo
                    {
                        Id = todoToEdit.Id,
                        Text = todoToEdit.Text,
                        IsCompleted = !todoToEdit.IsCompleted
                    });
        }
Exemplo n.º 2
0
        public static ImmutableArray <Todo> CompleteTodoReducer(ImmutableArray <Todo> previousState, CompleteTodoAction action)
        {
            var todoToEdit = previousState.First(todo => todo.Id == action.TodoId);

            return(previousState
                   .Replace(todoToEdit, new Todo
            {
                Id = todoToEdit.Id,
                Text = todoToEdit.Text,
                IsCompleted = !todoToEdit.IsCompleted
            }));
        }