/**
 * Model for interactiving with the db
 * @author bjora857
 */

function Transactionmodel() {

	this.getAllTransactions = function(callback, date) {

		if (date === undefined) {
			date = "2000-01-01-2099-01-01";
		}

		$.ajax({
			url: "/api/transactions/date/2000-01-01-2099-01-01/format/json",
			type: "GET",
			success: callback
		});

	};

	this.updateTransaction = function(transaction, callback) {

		$.ajax({
			type: "POST",
			url: "/api/transactionupdate/format/json",
			data: transaction.getJSON(),
			dataType: "script",
			success: callback
		});
	};

	this.removeTransaction = function(id, callback) {
		$.ajax({
			type: "DELETE",
			url: "/api/transaction/format/json/id/" + id,
			dataType: "script",
			success: callback
		});
	};

}
