public MangaInfo GetOrCreateMangaInfo(string containerPath, RecentItemList <IMangaItem> lastAddedCollection, bool saveToDatabase) { var item = GetByPath(containerPath); if (item != null) { return(item); } item = MangaInfo.Create(containerPath, saveToDatabase); if (!saveToDatabase) { return(item); } CheckCrcMatches(item); Items.Add(item); SaveChanges(); lastAddedCollection?.Add(item); return(item); MangaInfo GetByPath(string path) { var items = Items.Where(x => path.EndsWith(x.SubPath)).ToArray(); return(items.FirstOrDefault(x => x.FilePath == path)); } }
public void DeleteMangaInfo(MangaInfo item, bool addToDeletedItems) { if (addToDeletedItems) { var deleted = new DeletedMangaInfo(item); DeletedItems.Add(deleted); } Items.Remove(item); SaveChanges(); }
public DeletedMangaInfo(MangaInfo item) { Id = item.Id; Name = item.Name; DateAdded = item.DateAdded; DateDeleted = DateTime.Now; IsFolder = item.IsFolder; CRC32 = item.CRC32; SizeMb = item.SizeMb; FilePath = item.FilePath; FileCount = item.FileCount; }
/// <summary> /// Returns true if CRC should stop being checked. /// </summary> public bool CheckCrcMatches(MangaInfo preSavedItem) { var crcMatch = Items.FirstOrDefault(i => i.CRC32 == preSavedItem.CRC32); if (crcMatch != null) { var result = MessageBox.Show( @$ "Found a CRC32 Match This: {preSavedItem} Match: {crcMatch} Press Yes to delete this and open match. Press No add this item to database. Press cancel to skip this message (will default to adding).",