public ActionResult Index(int pageNumber = 1, int take = 5, int?assignedToId = null, int?issueStatusId = null, string reason = null)
        {
            if (pageNumber <= 0)
            {
                pageNumber = 1;
            }

            if (take < 1)
            {
                take = 5;
            }

            var galleryUserName = GetLoggedInUser();

            var viewModel = new SupportRequestsViewModel();

            viewModel.ItemsPerPage           = take;
            viewModel.CurrentPageNumber      = pageNumber;
            viewModel.AssignedToChoices      = GetListOfAdmins();
            viewModel.IssueStatusNameChoices = GetListOfIssueStatuses();
            viewModel.AssignedToFilter       = assignedToId;
            viewModel.ReasonChoices          = GetListOfReasons(reason);
            viewModel.IssueStatusIdFilter    = issueStatusId;
            viewModel.ReasonFilter           = reason;

            var totalCount = _supportRequestService.GetIssueCount(assignedToId, reason, issueStatusId);

            if (totalCount % take == 0)
            {
                viewModel.MaxPage = totalCount / take;
            }
            else
            {
                viewModel.MaxPage = totalCount / take + 1;
            }

            var issues = GetSupportRequests(pageNumber, take, assignedToId, reason, issueStatusId);

            // show current admin issues first,
            // then sort by issue status, showing new first, then working, then waiting for customer, then resolved,
            // then sort by creation time descending
            var orderedIssues = issues
                                .OrderByDescending(i => i.AssignedToGalleryUsername == galleryUserName)
                                .ThenBy(i => SortByIssueStatus(i.IssueStatusId))
                                .ThenByDescending(i => i.Issue.CreatedDate)
                                .ToList();

            viewModel.Issues.AddRange(orderedIssues);

            return(View(viewModel));
        }
Exemple #2
0
        public async Task <ActionResult> Index(int pageNumber = 1, int take = _defaultTakeCount, int?assignedToId = null, int?issueStatusId = null, string reason = null)
        {
            if (pageNumber <= 0)
            {
                pageNumber = 1;
            }

            if (take < 1)
            {
                take = _defaultTakeCount;
            }

            var viewModel = new SupportRequestsViewModel();

            viewModel.ItemsPerPage           = take;
            viewModel.CurrentPageNumber      = pageNumber;
            viewModel.AssignedToChoices      = GetListOfAdmins();
            viewModel.IssueStatusNameChoices = GetListOfIssueStatuses();
            viewModel.AssignedToFilter       = assignedToId;
            viewModel.ReasonChoices          = GetListOfReasons(reason);
            viewModel.IssueStatusIdFilter    = issueStatusId;
            viewModel.ReasonFilter           = reason;

            var totalCount = _supportRequestService.GetIssueCount(assignedToId, reason, issueStatusId);

            if (totalCount % take == 0)
            {
                viewModel.MaxPage = totalCount / take;
            }
            else
            {
                viewModel.MaxPage = totalCount / take + 1;
            }

            var issues = await GetSupportRequestsAsync(pageNumber, take, assignedToId, reason, issueStatusId);

            viewModel.Issues.AddRange(issues);

            return(View(viewModel));
        }