working example

This commit is contained in:
2018-02-26 12:07:12 +01:00
parent e5ae0c75cf
commit 0cc84f5a58
17 changed files with 4526 additions and 130 deletions

View File

@@ -1,35 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Track_1 = require("../../domain/models/Track");
var VinylCatalog = /** @class */ (function () {
function VinylCatalog() {
this.vinylList = new Array(new Track_1.Track(1, "DNA.", "Kendrick Lamar", 340), new Track_1.Track(2, "Come Down", "Anderson Paak.", 430), new Track_1.Track(3, "DNA.", "Kendrick Lamar", 340), new Track_1.Track(4, "DNA.", "Kendrick Lamar", 340), new Track_1.Track(5, "DNA.", "Kendrick Lamar", 340));
}
VinylCatalog.prototype.get = function () {
return this.vinylList;
};
VinylCatalog.prototype.getById = function (id) {
return this.vinylList.filter(function (track) { return track.Id == id; }).pop();
};
VinylCatalog.prototype.add = function (track) {
return this.vinylList.push(track);
};
VinylCatalog.prototype.edit = function (id, track) {
var existingTrack = this.getById(id);
existingTrack.Artist = track.Artist;
existingTrack.Title = track.Title;
existingTrack.Duration = track.Duration;
return existingTrack;
};
VinylCatalog.prototype.delete = function (id) {
var track = this.getById(id);
if (track) {
var targetIndex = this.vinylList.indexOf(track);
if (targetIndex < -1)
return null;
return this.vinylList.splice(targetIndex, 1)[0];
}
};
return VinylCatalog;
}());
exports.VinylCatalog = VinylCatalog;