public async Task AddOrUpdateExport(BeatmapExport export) { if (export.BeatmapId == null || export.BeatmapId.Length == 0) { Console.WriteLine("No beatmap found."); return; } var beatmap = await Beatmaps.FindAsync(export.BeatmapId); if (beatmap == null) { Console.WriteLine("No beatmap found."); return; } var exist = await Exports.FindAsync(export.Id); if (exist != null) { exist.UpdateTime = DateTime.Now; exist.ExportPath = export.ExportPath; exist.IsValid = true; } else { export.Beatmap = beatmap; Exports.Add(export); } await SaveChangesAsync(); }
public async Task AddOrUpdateStoryboardByBeatmap(BeatmapStoryboard storyboard) { if (storyboard.BeatmapId == null || storyboard.BeatmapId.Length == 0) { Console.WriteLine("No beatmap found."); return; } var beatmap = await Beatmaps.FindAsync(storyboard.BeatmapId); if (beatmap == null) { Console.WriteLine("No beatmap found."); } var exist = await Storyboards.FindAsync(storyboard.Id); if (exist != null) { exist.StoryboardVideoPath = storyboard.StoryboardVideoPath; } else { storyboard.Beatmap = beatmap; Storyboards.Add(storyboard); } await SaveChangesAsync(); }
/// <summary> /// ignore null columns /// </summary> /// <param name="beatmapConfig"></param> /// <returns></returns> public async Task AddOrUpdateBeatmapConfig(BeatmapConfig beatmapConfig) { if (beatmapConfig.BeatmapId == null || beatmapConfig.BeatmapId.Length == 0) { Console.WriteLine("No beatmap found."); return; } var beatmap = await Beatmaps.FindAsync(beatmapConfig.BeatmapId); if (beatmap == null) { Console.WriteLine("No beatmap found."); } var exist = await BeatmapConfigs.FindAsync(beatmapConfig.Id); if (exist == null) { BeatmapConfigs.Add(beatmapConfig); } else { if (beatmapConfig.MainVolume != null) { exist.MainVolume = beatmapConfig.MainVolume.Value; } if (beatmapConfig.MusicVolume != null) { exist.MusicVolume = beatmapConfig.MusicVolume.Value; } if (beatmapConfig.HitsoundVolume != null) { exist.HitsoundVolume = beatmapConfig.HitsoundVolume.Value; } if (beatmapConfig.SampleVolume != null) { exist.SampleVolume = beatmapConfig.SampleVolume.Value; } if (beatmapConfig.Offset != null) { exist.Offset = beatmapConfig.Offset.Value; } if (beatmapConfig.PlaybackRate != null) { exist.PlaybackRate = beatmapConfig.PlaybackRate.Value; } if (beatmapConfig.PlayUseTempo != null) { exist.PlayUseTempo = beatmapConfig.PlayUseTempo.Value; } if (beatmapConfig.LyricOffset != null) { exist.LyricOffset = beatmapConfig.LyricOffset.Value; } if (beatmapConfig.ForceLyricId != null) { exist.ForceLyricId = beatmapConfig.ForceLyricId; } } await SaveChangesAsync(); }