public static async Task AddToCollectionAsync(Collection col, IList <Beatmap> entries) { if (entries.Count <= 0) { return; } if (string.IsNullOrEmpty(col.ImagePath)) { var first = entries[0]; var osuFile = await OsuFile.ReadFromFileAsync(Path.Combine(Domain.OsuSongPath, first.FolderName, first.BeatmapFileName)); if (osuFile.Events.BackgroundInfo != null) { var imgPath = Path.Combine(Domain.OsuSongPath, first.FolderName, osuFile.Events.BackgroundInfo.Filename); if (File.Exists(imgPath)) { col.ImagePath = imgPath; _appDbOperator.UpdateCollection(col); } } } _appDbOperator.AddMapsToCollection(entries, col); }
public static CollectionViewModel CopyFrom(Collection collection) => new CollectionViewModel { Id = collection.Id, Name = collection.Name, Index = collection.Index, ImagePath = collection.ImagePath, Description = collection.Description, CreateTime = collection.CreateTime, Locked = collection.Locked };
public static async Task AddToCollectionAsync(Collection col, Beatmap entry) { if (string.IsNullOrEmpty(col.ImagePath)) { var osuFile = await OsuFile.ReadFromFileAsync(Path.Combine(Domain.OsuSongPath, entry.FolderName, entry.BeatmapFileName)); if (osuFile.Events.BackgroundInfo != null) { var imgPath = Path.Combine(Domain.OsuSongPath, entry.FolderName, osuFile.Events.BackgroundInfo.Filename); if (File.Exists(imgPath)) { col.ImagePath = imgPath; DbOperate.UpdateCollection(col); } } } DbOperate.AddMapToCollection(entry, col); }