added example files

This commit is contained in:
2018-02-18 00:18:16 +01:00
parent 3654c08bc2
commit e5ae0c75cf
17 changed files with 342 additions and 0 deletions

35
dist/adapters/music/VinylCatalog.js vendored Normal file
View File

@@ -0,0 +1,35 @@
"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;