Пример #1
0
        public virtual ActionResult Profiles(string username)
        {
            var user = UserService.FindByUsername(username);

            if (user == null)
            {
                return(HttpNotFound());
            }

            var packages = (from p in PackageService.FindPackagesByOwner(user)
                            where p.Listed
                            orderby p.Version descending
                            group p by p.PackageRegistration.Id)
                           .Select(c => new PackageViewModel(c.First()))
                           .ToList();

            var model = new UserProfileModel
            {
                Username     = user.Username,
                EmailAddress = user.EmailAddress,
                Packages     = packages,
                TotalPackageDownloadCount = packages.Sum(p => p.TotalDownloadCount)
            };

            return(View(model));
        }
Пример #2
0
        public virtual ActionResult Profiles(string username)
        {
            var user = userService.FindByUsername(username);

            if (user == null)
            {
                return(HttpNotFound());
            }

            var packages = (from p in packageService.FindPackagesByOwner(user) where p.Listed orderby p.Version descending group p by p.PackageRegistration.Id).Select(c => new PackageViewModel(c.First()))
                           .ToList();

            var packagesInModeration =
                (from p in packageService.FindPackagesByOwner(user) where p.Status == PackageStatusType.Submitted orderby p.Version descending group p by p.PackageRegistration.Id).Select(
                    c => new PackageViewModel(c.First())).ToList();

            //var userProfiles = profilesService.GetUserProfiles(user).ToList();
            var userProfiles     = (from p in profilesService.GetUserProfiles(user) orderby p.Name select p).Select(c => new UserSiteProfileViewModel(c)).ToList();
            var completedCourses = (from p in courseAchievementsService.GetUserCourseAchievements(user) orderby p.CompletedDate select p).Select(c => new CourseAchievementViewModel(c)).ToList();
            var model            = new UserProfileModel
            {
                Username                  = user.Username,
                EmailAddress              = user.EmailAddress,
                Packages                  = packages,
                PackagesModerationQueue   = packagesInModeration,
                TotalPackageDownloadCount = packages.Sum(p => p.TotalDownloadCount),
                UserProfiles              = userProfiles,
                CompletedCourses          = completedCourses,
            };

            return(View("~/Views/Users/Profiles.cshtml", model));
        }
Пример #3
0
        public virtual ActionResult Profiles(string username, int page = 1)
        {
            var user = _userService.FindByUsername(username);

            if (user == null || user.IsDeleted)
            {
                return(HttpNotFound());
            }

            var packages = _packageService.FindPackagesByAnyMatchingOwner(user, includeUnlisted: false)
                           .OrderByDescending(p => p.PackageRegistration.DownloadCount)
                           .Select(p => new ListPackageItemViewModel(p)
            {
                DownloadCount = p.PackageRegistration.DownloadCount
            }).ToList();

            var model = new UserProfileModel(user, packages, page - 1, Constants.DefaultPackageListPageSize, Url);

            return(View(model));
        }
Пример #4
0
        public virtual ActionResult Profiles(string username, int page = 1, bool showAllPackages = false)
        {
            var user = UserService.FindByUsername(username);

            if (user == null)
            {
                return(HttpNotFound());
            }

            var packages = PackageService.FindPackagesByOwner(user, includeUnlisted: false)
                           .OrderByDescending(p => p.PackageRegistration.DownloadCount)
                           .Select(p => new PackageViewModel(p)
            {
                DownloadCount = p.PackageRegistration.DownloadCount
            }).ToList();

            var model = new UserProfileModel(user, packages, page - 1, Constants.DefaultPackageListPageSize, Url);

            model.ShowAllPackages = showAllPackages;

            return(View(model));
        }
Пример #5
0
        public virtual ActionResult Profiles(string username, int page = 1)
        {
            var currentUser = GetCurrentUser();
            var user        = UserService.FindByUsername(username);

            if (user == null || user.IsDeleted)
            {
                return(HttpNotFound());
            }

            var packages = PackageService.FindPackagesByOwner(user, includeUnlisted: false)
                           .Where(p => p.PackageStatusKey == PackageStatus.Available)
                           .OrderByDescending(p => p.PackageRegistration.DownloadCount)
                           .Select(p => new ListPackageItemViewModel(p, currentUser)
            {
                DownloadCount = p.PackageRegistration.DownloadCount
            }).ToList();

            var model = new UserProfileModel(user, currentUser, packages, page - 1, GalleryConstants.DefaultPackageListPageSize, Url);

            return(View(model));
        }
Пример #6
0
        public virtual ActionResult Profiles(string username)
        {
            var user = UserService.FindByUsername(username);

            if (user == null)
            {
                return(HttpNotFound());
            }

            var packages = PackageService.FindPackagesByOwner(user, includeUnlisted: false)
                           .Select(p => new PackageViewModel(p)
            {
                DownloadCount = p.PackageRegistration.DownloadCount,
                Version       = null
            }).ToList();

            var model = new UserProfileModel(user)
            {
                Packages = packages,
                TotalPackageDownloadCount = packages.Sum(p => p.TotalDownloadCount),
            };

            return(View(model));
        }
        public virtual ActionResult Profiles(string username)
        {
            var user = _userService.FindByUsername(username);
            if (user == null)
            {
                return HttpNotFound();
            }

            var packages = (from p in _packageService.FindPackagesByOwner(user)
                            where p.Listed
                            orderby p.Version descending
                            group p by p.PackageRegistration.Id)
                .Select(c => new PackageViewModel(c.First()))
                .ToList();

            var model = new UserProfileModel
                {
                    Username = user.Username,
                    EmailAddress = user.EmailAddress,
                    Packages = packages,
                    TotalPackageDownloadCount = packages.Sum(p => p.TotalDownloadCount)
                };

            return View(model);
        }
Пример #8
0
        public virtual ActionResult Profiles(string username, int page = 1, bool showAllPackages = false)
        {
            var user = UserService.FindByUsername(username);
            if (user == null)
            {
                return HttpNotFound();
            }

            var packages = PackageService.FindPackagesByOwner(user, includeUnlisted: false)
                .OrderByDescending(p => p.PackageRegistration.DownloadCount)
                .Select(p => new PackageViewModel(p)
                {
                    DownloadCount = p.PackageRegistration.DownloadCount
                }).ToList();

            var model = new UserProfileModel(user, packages, page - 1, Constants.DefaultPackageListPageSize, Url);
            model.ShowAllPackages = showAllPackages;

            return View(model);
        }
Пример #9
0
        public virtual ActionResult Profiles(string username)
        {
            var user = UserService.FindByUsername(username);
            if (user == null)
            {
                return HttpNotFound();
            }

            var packages = PackageService.FindPackagesByOwner(user, includeUnlisted: false)
                .OrderByDescending(p => p.PackageRegistration.DownloadCount)
                .Select(p => new PackageViewModel(p)
                {
                    DownloadCount = p.PackageRegistration.DownloadCount,
                    Version = null
                }).ToList();

            var model = new UserProfileModel(user)
            {
                Packages = packages,
                TotalPackageDownloadCount = packages.Sum(p => p.TotalDownloadCount),
            };

            return View(model);
        }
Пример #10
0
        public virtual ActionResult Profiles(string username)
        {
            var user = userService.FindByUsername(username);
            if (user == null) return HttpNotFound();

            var packages = (from p in packageService.FindPackagesByOwner(user) where p.Listed orderby p.Version descending group p by p.PackageRegistration.Id).Select(c => new PackageViewModel(c.First())).ToList();

            var packagesInModeration =
                (from p in packageService.FindPackagesByOwner(user) where p.Status == PackageStatusType.Submitted orderby p.Version descending group p by p.PackageRegistration.Id).Select(
                    c => new PackageViewModel(c.First())).ToList();

            //var userProfiles = profilesService.GetUserProfiles(user).ToList();
            var userProfiles = (from p in profilesService.GetUserProfiles(user) orderby p.Name select p).Select(c => new UserSiteProfileViewModel(c)).ToList();

            var model = new UserProfileModel
            {
                Username = user.Username,
                EmailAddress = user.EmailAddress,
                Packages = packages,
                PackagesModerationQueue = packagesInModeration,
                TotalPackageDownloadCount = packages.Sum(p => p.TotalDownloadCount),
                UserProfiles = userProfiles
            };

            return View("~/Views/Users/Profiles.cshtml", model);
        }
Пример #11
0
        public virtual ActionResult Profiles(string username)
        {
            var user = userService.FindByUsername(username);
            if (user == null)
            {
                return HttpNotFound();
            }

            var packages = (from p in packageService.FindPackagesByOwner(user)
                            select new PackageViewModel(p)).ToList();

            var model = new UserProfileModel
            {
                Username = user.Username,
                EmailAddress = user.EmailAddress,
                Packages = packages,
                TotalPackageDownloadCount = packages.Sum(p => p.TotalDownloadCount)
            };

            return View(model);
        }