public bool IsFreeDiscItemDownloadOnQueue(FreeDiscItem itemToCheck) { if(itemToCheck == null) return false; if(DownloadItemList.Count > 0) for (int i = 0; i < DownloadItemList.Count; i++) if(DownloadItemList[i].IdFreedisc == itemToCheck.IdFreedisc) return true; return false; }
// add new item from search model public async Task AddNewItemToDownloadAsync(FreeDiscItem itemToAdd) { Debug.WriteLine("AddNewItemToDownload()"); if (itemToAdd == null) { Debug.WriteLine("AddNewItemToDownload: itemToAdd = null"); return; } if (IsFreeDiscItemDownloadOnQueue(itemToAdd)) { Debug.WriteLine( "Element już istnieje na liście do pobrania" + itemToAdd.Title ); return; } var downloaditem = new FreeDiscItemDownload(itemToAdd) { RowEven = (DownloadItemList?.Count ?? 0) > 0 ? !DownloadItemList[0]?.RowEven ?? true : true }; DownloadItemList.Insert(0, downloaditem); await _freeDiscItemDownloadRepository.SaveToDBAsync(downloaditem); await DownloadQueueProcessAsync(); }