private async Task <Song> GetSongDto(Song song, SongPick pickReason) { var user = await GetUser(); if (user != null && song.Id != null) { var songLikeId = Like.GetLikeId(user.Id, song.Id); var songLike = await DbSession.LoadOptionalAsync <Like>(songLikeId); var status = songLike != null ? songLike.Status : LikeStatus.None; return(song.ToDto(status, pickReason)); } return(song.ToDto()); }
public static SongPickReasons FromSoleReason(SongPick playedReason) { return(new SongPickReasons { SoleReason = playedReason }); }
// Add a property here? It should probably be added to .ToDto() /// <summary> /// Creates a new song object that's ready to be sent as a data transfer object over to the client. /// </summary> /// <param name="likeStatus">The like status for the song.</param> /// <param name="playedReason"></param> /// <returns></returns> public Song ToDto(LikeStatus likeStatus, SongPick playedReason) { return(ToDto(likeStatus, SongPickReasons.FromSoleReason(playedReason))); }