Beispiel #1
0
 public Userkey SaveKeyForUser(int userId, Guid newKey) {
     Userkey existingUserkey = GetAccessKeyForUser(userId, false);
     if (existingUserkey != null) {
         existingUserkey.AccessKey = newKey;
         _userkeyContentItemRepository.Update(existingUserkey);
         return existingUserkey;
     }
     var newUserkey = new Userkey { UserId = userId, AccessKey = newKey};
     _userkeyContentItemRepository.Create(newUserkey);
     return newUserkey;
 }
 private IEnumerable<Package> GetUserUnfinshedPackages(int userId, Userkey key) {
     return _galleryPackageService.GetUnfinishedPackages(_userkeyPackageService.GetUserkeyPackagesForUser(userId).Select(up => up.PackageId), key.AccessKey);
 }
 private IEnumerable<PackagePart> GetUnpublishedPackagesUserCanManage(IUser user, Userkey key) {
     if (user != null) {
         IEnumerable<PackagePart> packagesByUserkey = _userkeyPackageService.GetPackagesByUserkey(key.Id, true);
         return packagesByUserkey.Where(up => !up.ContentItem.IsPublished());
     }
     else {
         return new List<PackagePart>();
     }
 }
 private int GetCountOfPublishedPackagesUserCanManage(IUser user, Userkey key) {
     if (user != null) {
         return _packagePrivilegeChecker.UserCanManageAllPackages(user) ? _packageService.CountOfPackages(p => p.IsRecommendedVersion) : _userkeyPackageService.CountOfUsersPackages(key.Id, p => p.IsRecommendedVersion);
     }
     return 0;
 }
 private IEnumerable<PackagePart> GetPublishedPackagesUserCanManage(IUser user, Userkey key, int startingIndex, int pageSize) {
     IEnumerable<PackagePart> recommendedPackages;
     if (user != null) {
         recommendedPackages = _packagePrivilegeChecker.UserCanManageAllPackages(user) ?
             _packageService.Get(startingIndex, pageSize, p => p.IsRecommendedVersion) :
             _userkeyPackageService.GetPackagesByUserkey(key.Id, startingIndex, pageSize, p => p.IsRecommendedVersion);
     } else {
         recommendedPackages = new List<PackagePart>();
     }
     return recommendedPackages;
 }