public QueryViewModel(IEnumerable <string> recordTypes, IRecordService recordService, IApplicationController controller, bool allowQuery = false, bool loadInitially = false, CustomGridFunction closeFunction = null
                              , IEnumerable <CustomGridFunction> customFunctions = null)
            : base(controller)
        {
            CustomFunctions = customFunctions;
            LoadInitially   = loadInitially;
            AllowQuery      = allowQuery;
            RecordService   = recordService;
            if (closeFunction != null)
            {
                ReturnButton = new XrmButtonViewModel(closeFunction.Label, () => { closeFunction.Function(DynamicGridViewModel); }, controller);
            }
            QueryTypeButton = new XrmButtonViewModel("Change Query Type", ChangeQueryType, ApplicationController);
            DeleteSelectedConditionsButton = new XrmButtonViewModel("Delete Selected", () => DeleteSelected(), ApplicationController);
            GroupSelectedConditionsOr      = new XrmButtonViewModel("Group Selected Or", () => GroupSelected(FilterOperator.Or), ApplicationController);
            GroupSelectedConditionsAnd     = new XrmButtonViewModel("Group Selected And", () => GroupSelected(FilterOperator.And), ApplicationController);
            UngroupSelectedConditions      = new XrmButtonViewModel("Ungroup Selected", () => UnGroupSelected(), ApplicationController);
            ChangeQueryType();

            QueryTypeButton.IsVisible = AllowQuery;

            _recordTypes = recordTypes;
            if (_recordTypes.Count() == 1)
            {
                RecordType = _recordTypes.First();
            }
        }
        public QueryViewModel(IEnumerable <string> recordTypes, IRecordService recordService, IApplicationController controller, bool allowQuery = false, bool loadInitially = false, CustomGridFunction closeFunction = null
                              , IEnumerable <CustomGridFunction> customFunctions = null, bool allowCrud = true)
            : base(controller)
        {
            AllowCrud       = allowCrud;
            CustomFunctions = customFunctions;
            LoadInitially   = loadInitially;
            AllowQuery      = allowQuery;
            RecordService   = recordService;
            if (closeFunction != null)
            {
                ReturnButton = new XrmButtonViewModel(closeFunction.LabelFunc(null), () => { closeFunction.Function(DynamicGridViewModel); }, controller);
            }
            QueryTypeButton     = new XrmButtonViewModel("Change Query Type", ChangeQueryType, ApplicationController);
            LoadSavedViewButton = new XrmButtonViewModel("LOADVIEW", "Load Saved View", new XrmButtonViewModel[0], ApplicationController);

            DeleteSelectedConditionsButton = new XrmButtonViewModel("Delete Selected", () => DeleteSelected(), ApplicationController);
            GroupSelectedConditionsOr      = new XrmButtonViewModel("Group Selected Or", () => GroupSelected(FilterOperator.Or), ApplicationController);
            GroupSelectedConditionsAnd     = new XrmButtonViewModel("Group Selected And", () => GroupSelected(FilterOperator.And), ApplicationController);
            UngroupSelectedConditions      = new XrmButtonViewModel("Ungroup Selected", () => UnGroupSelected(), ApplicationController);

            NotInDeleteSelectedConditionsButton = new XrmButtonViewModel("Delete Selected", () => DeleteSelected(isNotIn: true), ApplicationController);
            NotInGroupSelectedConditionsOr      = new XrmButtonViewModel("Group Selected Or", () => GroupSelected(FilterOperator.Or, isNotIn: true), ApplicationController);
            NotInGroupSelectedConditionsAnd     = new XrmButtonViewModel("Group Selected And", () => GroupSelected(FilterOperator.And, isNotIn: true), ApplicationController);
            NotInUngroupSelectedConditions      = new XrmButtonViewModel("Ungroup Selected", () => UnGroupSelected(isNotIn: true), ApplicationController);

            RunQueryButton     = new XrmButtonViewModel("Run Query", QuickFind, ApplicationController);
            IncludeNotInButton = new XrmButtonViewModel("Add Not In Query", NotInSwitch, ApplicationController);
            ChangeQueryType();

            QueryTypeButton.IsVisible = AllowQuery;

            _recordTypes = recordTypes;
            if (_recordTypes.Count() == 1)
            {
                RecordType = _recordTypes.First();
            }
        }