public int?GetKey(string curatedFeedName) { var results = CuratedFeedRepository.GetAll() .Where(cf => cf.Name == curatedFeedName) .Select(cf => cf.Key).Take(1).ToArray(); return(results.Length > 0 ? (int?)results[0] : null); }
public IQueryable <Package> GetPackages(string curatedFeedName) { var packages = CuratedFeedRepository.GetAll() .Where(cf => cf.Name == curatedFeedName) .SelectMany(cf => cf.Packages.Where(cp => cp.Included).SelectMany(cp => cp.CuratedPackageVersions).Select(cpv => cpv.Package)); return(packages); }
public IQueryable <PackageRegistration> GetPackageRegistrations(string curatedFeedName) { var packageRegistrations = CuratedFeedRepository.GetAll() .Where(cf => cf.Name == curatedFeedName) .SelectMany(cf => cf.Packages.Select(cp => cp.PackageRegistration)); return(packageRegistrations); }
// I do wish CuratedPackage were called CuratedPackageRegistration public IQueryable <CuratedPackage> GetCuratedPackageRegistrations(string curatedFeedName) { var packages = CuratedFeedRepository.GetAll() .Where(cf => cf.Name == curatedFeedName) .SelectMany(cf => cf.Packages.Where(cp => cp.Included)); return(packages); }
public CuratedFeed GetFeedByName(string name) { if (IsCuratedFeedDisabled(name)) { return(null); } return(CuratedFeedRepository .GetAll() .SingleOrDefault(cf => cf.Name == name)); }
public IQueryable <Package> GetPackages(string curatedFeedName) { if (IsCuratedFeedDisabled(curatedFeedName)) { return(Enumerable.Empty <Package>().AsQueryable()); } var packages = CuratedFeedRepository.GetAll() .Where(cf => cf.Name == curatedFeedName) .SelectMany(cf => cf.Packages.SelectMany(cp => cp.PackageRegistration.Packages)); return(packages); }
public CuratedFeed GetFeedByKey(int key, bool includePackages) { IQueryable <CuratedFeed> query = CuratedFeedRepository.GetAll(); if (includePackages) { query = query .Include(cf => cf.Packages) .Include(cf => cf.Packages.Select(cp => cp.PackageRegistration)); } return(query .SingleOrDefault(cf => cf.Key == key)); }
public CuratedFeed GetFeedByName(string name, bool includePackages) { IQueryable <CuratedFeed> query = CuratedFeedRepository.GetAll(); if (includePackages) { query = query .Include(cf => cf.Packages) .Include(cf => cf.Packages.Select(cp => cp.PackageRegistration)); } return(query .SingleOrDefault(cf => cf.Name == name)); }
public CuratedPackage CreatedCuratedPackage( CuratedFeed curatedFeed, PackageRegistration packageRegistration, bool included = false, bool automaticallyCurated = false, string notes = null, bool commitChanges = true) { if (curatedFeed == null) { throw new ArgumentNullException(nameof(curatedFeed)); } if (packageRegistration == null) { throw new ArgumentNullException(nameof(packageRegistration)); } var curatedPackage = curatedFeed.Packages .SingleOrDefault(cp => cp.PackageRegistrationKey == packageRegistration.Key); if (curatedPackage == null) { curatedPackage = new CuratedPackage { PackageRegistration = packageRegistration, Included = included, AutomaticallyCurated = automaticallyCurated, Notes = notes, }; curatedFeed.Packages.Add(curatedPackage); } if (commitChanges) { CuratedFeedRepository.CommitChanges(); } return(curatedPackage); }
public void ModifyCuratedPackage( int curatedFeedKey, int curatedPackageKey, bool included) { var curatedFeed = GetFeedByKey(curatedFeedKey, includePackages: true); if (curatedFeed == null) { throw new InvalidOperationException("The curated feed does not exist."); } var curatedPackage = curatedFeed.Packages.SingleOrDefault(cp => cp.Key == curatedPackageKey); if (curatedPackage == null) { throw new InvalidOperationException("The curated package does not exist."); } curatedPackage.Included = included; CuratedFeedRepository.CommitChanges(); }
public IEnumerable <CuratedFeed> GetFeedsForManager(int managerKey) { return(CuratedFeedRepository.GetAll() .Where(cf => cf.Managers.Any(u => u.Key == managerKey))); }
public CuratedPackage CreatedCuratedPackage( CuratedFeed curatedFeed, Package package, bool included = false, bool automaticallyCurated = false, string notes = null, bool commitChanges = true) { if (curatedFeed == null) { throw new ArgumentNullException("curatedFeed"); } if (package == null) { throw new ArgumentNullException("package"); } var curatedPackageRegistration = curatedFeed.Packages .SingleOrDefault(cp => cp.PackageRegistrationKey == package.PackageRegistration.Key); var isFirstPackageInRegistration = false; if (curatedPackageRegistration == null) { curatedPackageRegistration = new CuratedPackage { PackageRegistration = package.PackageRegistration, PackageRegistrationKey = package.PackageRegistrationKey, Included = included, AutomaticallyCurated = automaticallyCurated, Notes = notes, }; curatedFeed.Packages.Add(curatedPackageRegistration); isFirstPackageInRegistration = true; } if (!curatedPackageRegistration.CuratedPackageVersions.Any(p => p.PackageKey == package.Key)) { var curatedPackageVersion = new CuratedPackageVersion { CuratedFeed = curatedFeed, CuratedFeedKey = curatedFeed.Key, PackageRegistration = package.PackageRegistration, PackageRegistrationKey = package.PackageRegistrationKey, Package = package, PackageKey = package.Key, }; // Make sure we set IsLatest + IsLatestStable for the first package, because // UpdateIsLatest won't be able to see this registration if we don't commit. // If it's the first package in the registration, then it's definitely the // latest. It's the latest stable package only if it's not a pre-release. if (isFirstPackageInRegistration) { curatedPackageVersion.IsLatest = true; curatedPackageVersion.IsLatestStable = !package.IsPrerelease; } curatedPackageRegistration.CuratedPackageVersions.Add(curatedPackageVersion); } if (commitChanges) { CuratedFeedRepository.CommitChanges(); } return(curatedPackageRegistration); }