protected void GetCurrentLatestVersionPackages(int feedId, string packageId, IInternalPackageRepository packageRepository, out IInternalPackage latestAbsoluteVersionPackage, out IInternalPackage latestVersionPackage) { latestAbsoluteVersionPackage = null; latestVersionPackage = null; List <IInternalPackage> versionsOfPackage; using (ITransaction transaction = Store.BeginTransaction()) { versionsOfPackage = packageRepository.GetVersions(transaction, packageId, true).ToList(); } if (versionsOfPackage.Any()) { foreach (var versionOfPackage in versionsOfPackage) { if (versionOfPackage.IsAbsoluteLatestVersion) { latestAbsoluteVersionPackage = versionOfPackage; } if (versionOfPackage.IsLatestVersion) { latestVersionPackage = versionOfPackage; } if (latestVersionPackage != null && latestAbsoluteVersionPackage != null) { break; } } } }
protected void GetNextLatestVersionPackages(int feedId, string packageId, IInternalPackageRepository packageRepository, out IInternalPackage latestAbsoluteVersionPackage, out IInternalPackage latestVersionPackage) { List <IInternalPackage> versionsOfPackage; using (ITransaction transaction = Store.BeginTransaction()) { versionsOfPackage = packageRepository.GetVersions(transaction, packageId, true).ToList(); } if (versionsOfPackage.Any()) { latestVersionPackage = versionsOfPackage.Where(vp => !vp.IsPrerelease).Aggregate(versionsOfPackage[0], (highest, candiate) => candiate.GetSemanticVersion().CompareTo(highest.GetSemanticVersion()) > 0 ? candiate : highest); latestAbsoluteVersionPackage = versionsOfPackage.Aggregate(versionsOfPackage[0], (highest, candiate) => candiate.GetSemanticVersion().CompareTo(highest.GetSemanticVersion()) > 0 ? candiate : highest); } else { latestVersionPackage = null; latestAbsoluteVersionPackage = null; } }