Code Duplication    Length = 34-35 lines in 2 locations

v2/models/orders.js 1 location

@@ 197-231 (lines=35) @@
194
    },
195
196
    updateOrder: function(res, body) {
197
        if (Number.isInteger(parseInt(body.id))) {
198
            db.run("UPDATE orders SET customerName = ?," +
199
                " customerAddress = ?, customerZip = ?," +
200
                " customerCity = ?, customerCountry = ?, statusId = ?" +
201
                " WHERE apiKey = ? AND ROWID = ?",
202
            body.name,
203
            body.address,
204
            body.zip,
205
            body.city,
206
            body.country,
207
            body.status_id || 100,
208
            body.api_key,
209
            body.id, (err) => {
210
                if (err) {
211
                    return res.status(500).json({
212
                        errors: {
213
                            status: 500,
214
                            source: "PUT /order",
215
                            title: "Database error",
216
                            detail: err.message
217
                        }
218
                    });
219
                }
220
221
                return res.status(204).send();
222
            });
223
        } else {
224
            return res.status(400).json({
225
                errors: {
226
                    status: 400,
227
                    detail: "Required attribute order id (id) " +
228
                        " was not included in the request."
229
                }
230
            });
231
        }
232
    },
233
234
    deleteOrder: function(res, body) {

v1/models/orders.js 1 location

@@ 205-238 (lines=34) @@
202
    }
203
204
    function updateOrder(res, body) {
205
        if (Number.isInteger(parseInt(body.id))) {
206
            db.run("UPDATE orders SET customerName = ?, customerAddress = ?, customerZip = ?," +
207
                " customerCity = ?, customerCountry = ?, statusId = ?" +
208
                " WHERE apiKey = ? AND orderId = ?",
209
            body.name,
210
            body.address,
211
            body.zip,
212
            body.city,
213
            body.country,
214
            body.status_id || 100,
215
            body.api_key,
216
            body.id, (err) => {
217
                if (err) {
218
                    return res.status(500).json({
219
                        errors: {
220
                            status: 500,
221
                            source: "PUT /order",
222
                            title: "Database error",
223
                            detail: err.message
224
                        }
225
                    });
226
                } else {
227
                    res.status(204).send();
228
                }
229
            });
230
        } else {
231
            res.status(400).json({
232
                errors: {
233
                    status: 400,
234
                    detail: "Required attribute order id (id) " +
235
                        " was not included in the request."
236
                }
237
            });
238
        }
239
    }
240
241
    function deleteOrder(res, body) {