Search code examples
breeze

breeze - saving after loaded by stored procedure


I have a grid loaded with angular function calling stored procedure and i want to add to the grid a textbox and save it with breeze (part of the saving - insert will be pulling columns from the grid loaded by the sp) . how can i do that?

here is the angular (in my controller) used for loading the grid:

    $scope.loadSales = function () {
        $scope.pageLoaded = false;
    PService.SalesStatus($scope.filter).then(function (data) {
        $scope.lists = data;
        $scope.getcount= data.length;               
        $scope.pageLoaded = true;                
    });
}

here is my html of the grid:

 <md-content ng-controller="ListCtrl" >
                <md-tabs>              
                    <md-tab label="{{getcount}}">
                        <table>
                            <tr> 
                                <td width="10%">Not Sold:</td>
                                <td width="40%">
                                    <select name="singleSelect" ng-model="filter.NotSold">
                                        <option value=0>no</option>
                                        <option value=1>yes</option>
                                    </select>
                                </td>
                            </tr>    
                        </table>                                              

                        <md-button ng-click="loadSales()">Load Report</md-button>
                        <md-button ng-click="Save()">Save</md-button>

                        <div style="overflow: auto; font-size: 12px;width: 100%;">      
                            <table style="font-size: 12px">

                                <tr ng-repeat="item in lists | limitTo:1" ng-model-options="{ updateOn: 'default blur', debounce: {'default': 1000, 'blur': 0} }">
                                    <td ng-repeat="(key, val) in item">
                                        <span>
                                            <label style="color: black">{{key}} </label>
                                        </span>


                                    </td>
                                    <td>Qty to Save </td>
                                </tr>
                                <tr ng-repeat="item in lists" ng-init="filter">
                                    <td ng-repeat="(key, val) in item">

                                        <span> <label>{{val}} </label></span></td>
                                    <td><input type="number" name="saveForLater" ng-model="saveQty" /> </td>
                                </tr>

                            </table>
                        </div>

                    </md-tab>
                </md-tabs>
            </md-content>

here is the function that calls the c# stored procedure in my service:

function SalesStatus(filter) {
    return $http({
        method: 'GET',
        url: '/Services/SalesStatus',
        params: {notSold: filter.notSold }
    }).then(function (result)
    { return result.data; })
};

Solution

  • @LisaSolomon, starting from here, you're probably better off writing a standard webapi to do the update. Your breeze entities pulled from a stored procedure are not updateable and, not knowing the underlying table structure that informs you stored procedure, there is no way to suggest a breeze.js-way of updating/inserting the property that you want to manage. My approach has always been that if I can't represent the model organically on the client side, then I don't want to try to update it organically using breeze.