public Songbook GetById(Guid id) { //TODO: Profile me var songbook = _songbookDao.Get(id); if (songbook != null) { Hydrate(new List <SongbookDto> { songbook }); return(Songbook.From(songbook)); } return(null); }
public void SongbookAnalyseTest() { //Arrange string[] songbookdumies = { "FJ1 88", "Feiert Jesus I / 88", "DbH5 198", "Du bist Herr 5 / 198", "LuH 6", "Lehre uns Herr / 6", "Song 198", "Ich will dir danken /074", "Freude", "Songs Lothar Kosse / 001", "In Love with Jesus I / 002", "Wiedenester / 002", "Du bist Herr Kids I / 003", "RR Liederbuch" }; string erg = string.Empty; //Act foreach (string songbookdummy in songbookdumies) { Songbook test = new Songbook(songbookdummy); Debug.WriteLineIf(!string.IsNullOrEmpty(test.SbTitle), "#STitle : " + test.SbTitle); Debug.WriteLineIf(!string.IsNullOrEmpty(test.SbShortTitel), "#SShortTitle : " + test.SbShortTitel); Debug.WriteLineIf(!string.IsNullOrEmpty(test.SbBookNr), "#SNR : " + test.SbBookNr); Debug.WriteLineIf(!string.IsNullOrEmpty(test.SbSongNr), "#SSongNr : " + test.SbSongNr); Debug.WriteLineIf(!string.IsNullOrEmpty(test.SbTitle), string.Empty); erg += test.SbTitle + test.SbShortTitel + test.SbBookNr + test.SbSongNr; } //Assert Assert.IsTrue(erg == "Feiert JesusFJ188Feiert JesusFJ188Du bist HerrDbH5198Du bist Herr 5198Lehre uns Herr LuH6Lehre uns Herr LuH6Song198Ich will dir danken 074FreudeSongs Lothar Kosse 001In Love with Jesus1002Wiedenester 002Du bist Herr Kids1003RR Liederbuch"); }
public void RomanToIntTest() { //Arrange string[] songtitles = { "FJ1 88", "DbH5 198", "LuH 6", "SONG 198", "Feiert Jesus XIX / 88", "Du bist Herr 5 / 198", "Lehre uns Herr / 6", "Song / 198", "Ich will dir danken / 074", "Freude", "Songs Lothar Kosse / 001", "Ich will dir danken / 001", "In Love with Jesus I / 002", "Wiedenester / 002", "Du bist Herr Kids I / 003", "RR Liederbuch / 004" }; string[] titlesShort = { "FJ1 88", "DbH5 198", "LuH 6", "SONG 198", "", "", "", "", "", "", "", "" }; string erg = string.Empty; //string[] romeToInt = new string[songtitles.Length]; //Act foreach (var title in songtitles) { Songbook test = new Songbook(title); Debug.WriteLine(string.Format("#Songbook : {0}", title)); Debug.WriteLine(string.Format("#Songbook Titel : {0}", test.SbTitle)); Debug.WriteLine(string.Format("#Songbook Kurzform : {0}", test.SbShortTitel)); Debug.WriteLine(string.Format("#Songbook Nummer : {0}", test.SbBookNr)); Debug.WriteLine(string.Format("#Songbook Songnummer : {0}\n", test.SbSongNr)); erg += test.SbTitle + test.SbShortTitel + test.SbBookNr + test.SbSongNr; } //Assert Assert.IsTrue(erg == "Feiert JesusFJ188Du bist HerrDbH5198Lehre uns Herr LuH6SONG198Feiert JesusFJ1988Du bist Herr 5198Lehre uns Herr LuH6Song 198Ich will dir danken 074FreudeSongs Lothar Kosse 001Ich will dir danken 001In Love with Jesus1002Wiedenester 002Du bist Herr Kids1003RR Liederbuch 004"); }
public void Save(Songbook songbook) { //TODO: Profile me if (songbook.IsDestroyed) { foreach (var song in songbook.Songs) { foreach (var creator in song.Creators) { _creatorDao.Delete(creator.Id); } _songDao.Delete(song.Id); } _songbookDao.Delete(songbook.Id); } if (songbook.IsNew) { songbook.Id = Guid.NewGuid(); _songbookDao.Insert(songbook.ToDto()); } else { _songbookDao.Update(songbook.ToDto()); } foreach (var creator in songbook.Creators) { SaveCreator(creator, songbook.Id); } foreach (var song in songbook.Songs) { SaveSong(song, songbook.Id); } }
public ActionResult <SongbookResult> Post([FromBody] SongbookCreate songbook) { if (songbook == null) { return(BadRequest()); } _logger.LogDebug("SongbookController.Post called to create new songbook: {@songbook}", songbook); var dto = _mapper.Map <SongbookDto>(songbook); var newSongbook = Songbook.From(dto); //Perform validation if (!newSongbook.IsValid) { newSongbook.Validate().AddToModelState(ModelState, null); _logger.LogWarning("{method} failed model validation (ModelState: {@modelState}), returning Unprocessable Entity", nameof(Post), ModelState.Values.SelectMany(v => v.Errors)); return(InvalidModelStateResponseFactory.GenerateResponseForInvalidModelState(ModelState, HttpContext)); } _repository.Save(newSongbook); return(CreatedAtRoute("GetSongbook", new { id = newSongbook.Id }, newSongbook)); }
private bool ImportHymnalFromJson(string rawJson) { var hymnDict = new Dictionary <Guid, Hymn>(); var lyricDict = new Dictionary <Guid, List <Lyric> >(); var songbook = JObject.Parse(rawJson); songbook.TryGetValue("Title", out JToken title); var sb = new Songbook() { Title = title?.Value <string>() ?? "You should really title this" }; _connection.InsertOrReplaceAsync(sb).Wait(); // This sets the Id property var hymns = songbook["Hymns"]; var tasks = new List <Task>(); // Load it all into memory foreach (var h in hymns) { var insertGuid = Guid.NewGuid(); var hm = new Hymn() { SongbookId = sb.Id.GetValueOrDefault(), HymnNumber = h["hymnNumber"].Value <int>() }; hymnDict.Add(insertGuid, hm); List <Lyric> lyrics = new List <Lyric>(); for (int i = 0; i < h["lyrics"].Count(); i++) { var l = h["lyrics"][i]; var ly = new Lyric() { IsChorus = l["isChorus"].Value <bool>(), Verse = l["text"].Value <string>(), Order = i + 1 }; lyrics.Add(ly); } lyricDict.Add(insertGuid, lyrics); } _connection.InsertAllAsync(hymnDict.Values).Wait(); var masterLyricsList = new List <Lyric>(); foreach (var hymn in hymnDict) { var guid = hymn.Key; var hymnId = hymn.Value.Id.Value; var lyrics = lyricDict[guid]; if (lyrics != null) { foreach (var lyric in lyrics) { lyric.HymnId = hymnId; } masterLyricsList.AddRange(lyrics); } } _connection.InsertAllAsync(masterLyricsList); return(true); }