public virtual ActionResult DeleteRequest()
        {
            var currentUser = GetCurrentUser();

            if (currentUser == null || currentUser.IsDeleted)
            {
                return(HttpNotFound("User not found."));
            }

            var listPackageItems = _packageService
                                   .FindPackagesByAnyMatchingOwner(currentUser, includeUnlisted: true)
                                   .Select(p => new ListPackageItemViewModel(p, currentUser))
                                   .ToList();

            bool hasPendingRequest = _supportRequestService.GetIssues().Where((issue) => (issue.UserKey.HasValue && issue.UserKey.Value == currentUser.Key) &&
                                                                              string.Equals(issue.IssueTitle, Strings.AccountDelete_SupportRequestTitle) &&
                                                                              issue.Key != IssueStatusKeys.Resolved).Any();

            var model = new DeleteAccountViewModel()
            {
                Packages           = listPackageItems,
                User               = currentUser,
                AccountName        = currentUser.Username,
                HasPendingRequests = hasPendingRequest
            };

            return(View("DeleteAccount", model));
        }
Exemple #2
0
        public virtual ActionResult DeleteRequest()
        {
            var user = GetCurrentUser();

            if (user == null || user.IsDeleted)
            {
                return(HttpNotFound("User not found."));
            }

            var listPackageItems = _packageService
                                   .FindPackagesByOwner(user, includeUnlisted: true)
                                   .Select(p => new ListPackageItemViewModel(p))
                                   .ToList();

            bool hasPendingRequest = _supportRequestService.GetIssues().Where((issue) => string.Equals(issue.CreatedBy, user.Username) &&
                                                                              string.Equals(issue.IssueTitle, Strings.AccountDelete_SupportRequestTitle) &&
                                                                              issue.Key != IssueStatusKeys.Resolved).Any();

            var model = new DeleteAccountViewModel()
            {
                Packages           = listPackageItems,
                User               = user,
                AccountName        = user.Username,
                HasOrphanPackages  = listPackageItems.Any(p => p.Owners.Count <= 1),
                HasPendingRequests = hasPendingRequest
            };

            return(View("DeleteAccount", model));
        }