private void SetIWadGameFiles() { IEnumerable <IIWadData> iwads = DataSourceAdapter.GetIWads(); List <IGameFile> gameFileDataUpdate = new List <IGameFile>(); if (iwads.Any()) { IEnumerable <IGameFile> gameFiles = DataSourceAdapter.GetGameFiles(); foreach (IIWadData iwad in iwads) { IGameFile find = gameFiles.FirstOrDefault(x => x.FileName.ToLower() == iwad.FileName.ToLower().Replace(".wad", ".zip")); if (find != null) { if (!find.IWadID.HasValue) //this should mean the file was just added so we should set the pre-defined title { FillIwadData(find); gameFileDataUpdate.Add(find); find.IWadID = iwad.IWadID; DataSourceAdapter.UpdateGameFile(find, new GameFileFieldType[] { GameFileFieldType.IWadID }); } if (!iwad.GameFileID.HasValue) { iwad.GameFileID = find.GameFileID; DataSourceAdapter.UpdateIWad(iwad); } } else { Util.ThrowDebugException("This should not happen"); } } } }