Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Sending value which needs to be converted to enum
Message
 
 
To
All
General information
Forum:
Javascript
Category:
Coding, syntax & commands
Title:
Sending value which needs to be converted to enum
Miscellaneous
Thread ID:
01662620
Message ID:
01662620
Views:
34
Hi everybody,

I'm trying to create an object in JavaScript which is supposed to correspond to a C# object where columnType is C# Enum. I'm attempting to send it this way:
[{"columnDisplayName":"Category Description","columnName":"CategoryDescription","value":"Label","displayValue":"Label","strOperator":"Equals","Logic":"AND"},{"columnDisplayName":"Type Id","columnName":"LTypeId","columnType":1,"value":"7","displayValue":"7","strOperator":"Equals","Logic":"AND"}]
and I'm getting this error
- InnerException {"Could not cast or convert from System.Int64 to Siriusware.Models.Messages.SearchColumnTypes."} System.Exception {System.ArgumentException}


on this line of code:
filters.Filters = JsonConvert.DeserializeObject<List<SearchFilterItem>>(customFilterString);
Could it be because the first filter object doesn't have columnType at all?

Here is my JavaScript code:
$scope.filters = {};
                $scope.filters.filters = [];
                $scope.filters.basefilters = [];
                $scope.filters.logic = "AND";

                if ($scope.filterBy) {

                    let filter = {
                        columnDisplayName: 'Category Description',
                        columnName: 'CategoryDescription',
                        value: $scope.filterBy,
                        displayValue: $scope.filterBy,
                        strOperator: 'Equals', Logic: "AND"
                    };

                    $scope.filters.filters.push(filter);
                }

                if ($scope.type) {
                    let filter;

                    if ($.isNumeric($scope.type)) {
                        filter = {
                            columnDisplayName: 'Type Id',
                            columnName: 'LTypeId',
                            columnType: parseInt('1'),
                            value: $scope.type.toString(),
                            displayValue: $scope.type.toString(),
                            strOperator: 'Equals', Logic: "AND"
                        };
                    } // type is not a number
                    else {
                        filter = {
                            columnDisplayName: 'Type Description',
                            columnName: 'TypeDescription',
                            value: $scope.type,
                            displayValue: $scope.type,
                            strOperator: 'Equals', Logic: "AND"
                        };
                    }

                    $scope.filters.filters.push(filter);
                }
Do you see what I am doing wrong here?

Thanks in advance.
If it's not broken, fix it until it is.


My Blog
Reply
Map
View

Click here to load this message in the networking platform