Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e50dce0
commit d25db2e
Showing
4 changed files
with
70 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,22 +1,44 @@ | |||
using System.Collections.Generic; | using System.Collections.Generic; | ||
using System.Linq; | |||
using System.Web.Mvc; | |||
|
|
||
namespace NuGetGallery | namespace NuGetGallery | ||
{ | { | ||
public class UserProfileModel | public class UserProfileModel | ||
{ | { | ||
public UserProfileModel() { } | public UserProfileModel(User user, List<PackageViewModel> allPackages, int pageIndex, int pageSize, UrlHelper url) | ||
|
|||
public UserProfileModel(User user) | |||
{ | { | ||
Username = user.Username; | Username = user.Username; | ||
EmailAddress = user.EmailAddress; | EmailAddress = user.EmailAddress; | ||
UnconfirmedEmailAddress = user.UnconfirmedEmailAddress; | UnconfirmedEmailAddress = user.UnconfirmedEmailAddress; | ||
AllPackages = allPackages; | |||
TotalPackages = allPackages.Count; | |||
PackagePage = pageIndex; | |||
PackagePageSize = pageSize; | |||
|
|||
TotalPackageDownloadCount = AllPackages.Sum(p => p.TotalDownloadCount); | |||
|
|||
PackagePageTotalCount = (TotalPackages + PackagePageSize - 1) / PackagePageSize; | |||
|
|||
var pager = new PreviousNextPagerViewModel<PackageViewModel>(allPackages, pageIndex, PackagePageTotalCount, | |||
page => url.User(user, page)); | |||
|
|||
Pager = pager; | |||
PagedPackages = AllPackages.Skip(PackagePageSize * pageIndex) | |||
.Take(PackagePageSize).ToList(); | |||
} | } | ||
|
|
||
public string Username { get; set; } | public int PackagePageTotalCount { get; private set; } | ||
public string EmailAddress { get; set; } | public string Username { get; private set; } | ||
public string EmailAddress { get; private set; } | |||
public string UnconfirmedEmailAddress { get; set; } | public string UnconfirmedEmailAddress { get; set; } | ||
public ICollection<PackageViewModel> Packages { get; set; } | public ICollection<PackageViewModel> AllPackages { get; private set; } | ||
public int TotalPackageDownloadCount { get; set; } | public ICollection<PackageViewModel> PagedPackages { get; private set; } | ||
public int TotalPackageDownloadCount { get; private set; } | |||
public int TotalPackages { get; private set; } | |||
public int PackagePage { get; private set; } | |||
public int PackagePageSize { get; private set; } | |||
public IPreviousNextPager Pager { get; private set; } | |||
|
|||
} | } | ||
} | } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters