public static PlaybackModel ToModel(this PlaybackEntity playback) { return(new PlaybackModel { Id = playback.Id.ToItemId(), PlaybackTime = playback.PlaybackTime, }); }
private static void SyncSongPlaybacks(SongModel model, SongEntity entity) { if (model.PlaybacksCount != entity.PlaybacksCount + 1) { throw new InvalidOperationException($"There is some discrepancy in song playbacks for song {entity.Id}: {model.PlaybacksCount} != {entity.PlaybacksCount + 1}"); } if (model.LastPlaybackTime == null) { throw new InvalidOperationException("Last playback for the song is not set"); } entity.PlaybacksCount = model.PlaybacksCount; entity.LastPlaybackTime = model.LastPlaybackTime; var playbackEntity = new PlaybackEntity { PlaybackTime = model.LastPlaybackTime.Value, }; entity.Playbacks.Add(playbackEntity); }