示例#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
                    });
        }
示例#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
            }));
        }