private void BuildNumericFilter(TextboxQueueViewModel ctrlTextFilter, decimal? max, decimal? min, bool? isAndOr, bool isMaxEqual, bool isMinEqual)
        {
            if (min != null)
            {
                // If Filter is Arrears Days or Client Arrears Days is formatted as Integer
                if (ctrlTextFilter.Title == "# Arrears Days" || ctrlTextFilter.Title == "# Client Arrears Days")
                {
                    ctrlTextFilter.Value1 = ((int)min).ToString("D");
                }
                else
                {
                    ctrlTextFilter.Value1 = ((decimal)min).ToString("C2");
                }

                ctrlTextFilter.LocalSelectedOperators1 = ctrlTextFilter.AllOperators.FirstOrDefault(p => p.Value == CollectionQueueCondition.IsGreaterthan);
                if (isMinEqual)
                {
                    ctrlTextFilter.LocalSelectedOperators1 = ctrlTextFilter.AllOperators.FirstOrDefault(p => p.Value == CollectionQueueCondition.IsGreaterthanOrEqualTo);
                }
            }

            if (isAndOr != null)
            {
                if (isAndOr == true)
                {
                    ctrlTextFilter.LocalSelectedCondition = CollectionQueueOperators.And.ToString();
                }
                else
                {
                    ctrlTextFilter.LocalSelectedCondition = CollectionQueueOperators.Or.ToString();
                }
            }

            if (max != null)
            {
                if (min == null)
                {
                    // If Filter is Arrears Days or Client Arrears Days is formatted as Integer
                    if (ctrlTextFilter.Title == "# Arrears Days" || ctrlTextFilter.Title == "# Client Arrears Days")
                    {
                        ctrlTextFilter.Value1 = ((int)max).ToString("D");
                    }
                    else
                    {
                        ctrlTextFilter.Value1 = ((decimal)max).ToString("C2");
                    }

                    ctrlTextFilter.LocalSelectedOperators1 = ctrlTextFilter.AllOperators.FirstOrDefault(p => p.Value == CollectionQueueCondition.IsLessthan);
                    if (isMaxEqual)
                    {
                        ctrlTextFilter.LocalSelectedOperators1 = ctrlTextFilter.AllOperators.FirstOrDefault(p => p.Value == CollectionQueueCondition.IsLessthanOrEqualTo);
                    }

                }
                else
                {
                    // If Filter is Arrears Days or Client Arrears Days is formatted as Integer
                    if (ctrlTextFilter.Title == "# Arrears Days" || ctrlTextFilter.Title == "# Client Arrears Days")
                    {
                        ctrlTextFilter.Value2 = ((int)max).ToString("D");
                    }
                    else
                    {
                        ctrlTextFilter.Value2 = ((decimal)max).ToString("C2");
                    }

                    ctrlTextFilter.LocalSelectedOperators2 = ctrlTextFilter.AllOperators.FirstOrDefault(p => p.Value == CollectionQueueCondition.IsLessthan);
                    if (isMaxEqual)
                    {
                        ctrlTextFilter.LocalSelectedOperators2 = ctrlTextFilter.AllOperators.FirstOrDefault(p => p.Value == CollectionQueueCondition.IsLessthanOrEqualTo);
                    }
                }
            }
        }
        public CollectionsManagementViewModel()
        {
            this.Edit = new EditQueueViewModel(this);
            this.InstanceGUID = new Guid();
            this.IsQueueSelected = false;
            //this.CheckIsContentEditing = this.CheckContentEditing;
            this.PropertyChanged += this.ViewCollectionsManagementViewModel_PropertyChanged;
            ListAssignee = new CheckboxQueueViewModel();
            ListCompany = new CheckboxQueueViewModel();
            ListWorkgroup = new CheckboxQueueViewModel();
            ListFinancier = new CheckboxQueueViewModel();
            ListState = new CheckboxQueueViewModel();

            ClientName = new TextboxQueueViewModel("Client Name");
            Introducer = new TextboxQueueViewModel("Introducer");
            ArrearsAmount = new TextboxQueueViewModel("Arrears $");
            ArrearsDays = new TextboxQueueViewModel("# Arrears Days");
            InvestBalance = new TextboxQueueViewModel("Investment Balance");
            ClientArrearAmount = new TextboxQueueViewModel("Client Arrears $");
            ClientArrearDays = new TextboxQueueViewModel("# Client Arrears Days");
            ClientInvestBalance = new TextboxQueueViewModel("Client Investment Balance");

        }
        private async void LoadTextQuueFilterControl(TextboxQueueViewModel viewModel, bool isNumeric = false)
        {
            List<OperatorModel> AllOperators = new List<OperatorModel>();
            List<string> AllConditionals = new List<string>();

            AllConditionals.Add(CollectionQueueOperators.And.ToString());
            AllConditionals.Add(CollectionQueueOperators.Or.ToString());

            if (isNumeric)
            {
                AllOperators.Add(new OperatorModel() { Text = CollectionQueueCondition.None, Value = CollectionQueueCondition.None });
                AllOperators.Add(new OperatorModel() { Text = CollectionQueueCondition.IsGreaterthan, Value = CollectionQueueCondition.IsGreaterthan });
                AllOperators.Add(new OperatorModel() { Text = CollectionQueueCondition.IsGreaterthanOrEqualTo, Value = CollectionQueueCondition.IsGreaterthanOrEqualTo });
                AllOperators.Add(new OperatorModel() { Text = CollectionQueueCondition.IsLessthan, Value = CollectionQueueCondition.IsLessthan });
                AllOperators.Add(new OperatorModel() { Text = CollectionQueueCondition.IsLessthanOrEqualTo, Value = CollectionQueueCondition.IsLessthanOrEqualTo });
                viewModel.AllOperators = AllOperators;
                viewModel.LocalSelectedOperators1 = AllOperators.FirstOrDefault(op => op.Value == CollectionQueueCondition.None);
                viewModel.LocalSelectedOperators2 = AllOperators.FirstOrDefault(op => op.Value == CollectionQueueCondition.None);
            }
            else
            {
                viewModel.AllOperators = Operators.ToList();
                viewModel.LocalSelectedOperators1 = viewModel.AllOperators.FirstOrDefault(p => p.Value == null);
                viewModel.LocalSelectedOperators2 = viewModel.AllOperators.FirstOrDefault(p => p.Value == null);

            }

            viewModel.AllConditionals = AllConditionals;
            viewModel.LocalSelectedCondition = CollectionQueueOperators.And.ToString();
            viewModel.IsNumeric = isNumeric;
            viewModel.Value1 = string.Empty;
            viewModel.Value2 = string.Empty;
        }
        private ConditionModel ParserTextboxFilter(TextboxQueueViewModel textboxViewModel)
        {
            ConditionModel result = new ConditionModel();

            if (textboxViewModel.LocalSelectedCondition.Equals(CollectionQueueOperators.And.ToString()))
                result.isAnd = true;
            else if (textboxViewModel.LocalSelectedCondition.Equals(CollectionQueueOperators.Or.ToString()))
                result.isAnd = false;

            if (textboxViewModel.LocalSelectedOperators1.Text.Equals(CollectionQueueCondition.None) && textboxViewModel.LocalSelectedOperators2.Text.Equals(CollectionQueueCondition.None))
            {
                result.MinValue = null;
                result.MaxValue = null;
                result.isAnd = null;
            }
            else
            {
                if (textboxViewModel.LocalSelectedOperators1.Text.Equals(CollectionQueueCondition.None))
                {
                    if (textboxViewModel.LocalSelectedOperators2.Text.Equals(CollectionQueueCondition.IsGreaterthan))
                    {
                        result.MinValue = textboxViewModel.Value2 == "" ? 0 : Convert.ToDecimal(textboxViewModel.Value2);
                        result.MaxValue = null;
                        result.isAnd = null;
                    }
                    else if (textboxViewModel.LocalSelectedOperators2.Text.Equals(CollectionQueueCondition.IsLessthan))
                    {
                        result.MinValue = null;
                        result.MaxValue = textboxViewModel.Value2 == "" ? 0 : Convert.ToDecimal(textboxViewModel.Value2);
                        result.isAnd = null;
                    }
                }
                else if (textboxViewModel.LocalSelectedOperators1.Text.Equals(CollectionQueueCondition.IsGreaterthan))
                {
                    if (textboxViewModel.LocalSelectedOperators2.Text.Equals(CollectionQueueCondition.None))
                    {
                        result.MinValue = textboxViewModel.Value1 == "" ? 0 : Convert.ToDecimal(textboxViewModel.Value1);
                        result.MaxValue = null;
                        result.isAnd = null;
                    }
                    else if (textboxViewModel.LocalSelectedOperators2.Text.Equals(CollectionQueueCondition.IsLessthan))
                    {
                        result.MinValue = textboxViewModel.Value1 == "" ? 0 : Convert.ToDecimal(textboxViewModel.Value1);
                        result.MaxValue = textboxViewModel.Value2 == "" ? 0 : Convert.ToDecimal(textboxViewModel.Value2);
                    }
                    else if (textboxViewModel.LocalSelectedOperators2.Text.Equals(CollectionQueueCondition.IsGreaterthan))
                    {
                        if (result.isAnd == true)
                            result.MinValue = Convert.ToDouble(textboxViewModel.Value2) > Convert.ToDouble(textboxViewModel.Value1) ? Convert.ToDecimal(textboxViewModel.Value2) : Convert.ToDecimal(textboxViewModel.Value1);
                        else
                            result.MinValue = Convert.ToDouble(textboxViewModel.Value2) < Convert.ToDouble(textboxViewModel.Value1) ? Convert.ToDecimal(textboxViewModel.Value2) : Convert.ToDecimal(textboxViewModel.Value1);
                        result.MaxValue = null;
                        result.isAnd = null;
                    }
                }
                else if (textboxViewModel.LocalSelectedOperators1.Text.Equals(CollectionQueueCondition.IsLessthan))
                {
                    if (textboxViewModel.LocalSelectedOperators2.Text.Equals(CollectionQueueCondition.None))
                    {
                        result.MinValue = null;
                        result.MaxValue = Convert.ToDecimal(textboxViewModel.Value1);
                        result.isAnd = null;
                    }
                    else if (textboxViewModel.LocalSelectedOperators2.Text.Equals(CollectionQueueCondition.IsGreaterthan))
                    {
                        result.MinValue = Convert.ToDecimal(textboxViewModel.Value2);
                        result.MaxValue = Convert.ToDecimal(textboxViewModel.Value1);
                    }
                    else if (textboxViewModel.LocalSelectedOperators2.Text.Equals(CollectionQueueCondition.IsLessthan))
                    {
                        result.MinValue = null;
                        if (result.isAnd == true)
                            result.MaxValue = Convert.ToDouble(textboxViewModel.Value2) < Convert.ToDouble(textboxViewModel.Value1) ? Convert.ToDecimal(textboxViewModel.Value2) : Convert.ToDecimal(textboxViewModel.Value1);
                        else
                            result.MaxValue = Convert.ToDouble(textboxViewModel.Value2) > Convert.ToDouble(textboxViewModel.Value1) ? Convert.ToDecimal(textboxViewModel.Value2) : Convert.ToDecimal(textboxViewModel.Value1);
                        result.isAnd = null;
                    }
                }
            }
            return result;
        }
        private void BuildStringFilter(TextboxQueueViewModel ctrlTextFilter, CollectionQueueFilterString collectionqueuestring)
        {
            if (collectionqueuestring.IsAnd != null && collectionqueuestring.IsAnd == false)
            {
                ctrlTextFilter.LocalSelectedCondition = CollectionQueueOperators.Or.ToString();
            }
            else
            {
                ctrlTextFilter.LocalSelectedCondition = CollectionQueueOperators.And.ToString();
            }

            if (collectionqueuestring.Operator1 != null)
            {
                ctrlTextFilter.LocalSelectedOperators1 = ctrlTextFilter.AllOperators.FirstOrDefault(p => p.Value == collectionqueuestring.Operator1.Value.ToString());
                ctrlTextFilter.Value1 = collectionqueuestring.Value1 == null ? "" : collectionqueuestring.Value1;
            }

            if (collectionqueuestring.Operator2 != null)
            {
                ctrlTextFilter.LocalSelectedOperators2 = ctrlTextFilter.AllOperators.FirstOrDefault(p => p.Value == collectionqueuestring.Operator2.Value.ToString());
                ctrlTextFilter.Value2 = collectionqueuestring.Value2 == null ? "" : collectionqueuestring.Value2;
            }
        }