public void Execute()
        {
            String searchValue = CommonHelper.GetSearchValue(_httpContext);

            /* State retrieval */
            PreApprovalViewModel preApprovalViewModel = null;

            if (_httpContext.Session[SessionHelper.PreApprovalViewModel] != null)
            {
                preApprovalViewModel = new PreApprovalViewModel().FromXml(_httpContext.Session[SessionHelper.PreApprovalViewModel].ToString());
            }
            else
            {
                preApprovalViewModel = new PreApprovalViewModel();
            }

            PreApprovalListState preApprovalListState = null;

            if (_httpContext.Session[SessionHelper.PreApprovalListState] != null)
            {
                preApprovalListState = ( PreApprovalListState )_httpContext.Session[SessionHelper.PreApprovalListState];
            }
            else
            {
                preApprovalListState = new PreApprovalListState();
            }

            UserAccount user = null;

            if (_httpContext.Session[SessionHelper.UserData] != null && ((UserAccount)_httpContext.Session[SessionHelper.UserData]).Username == _httpContext.User.Identity.Name)
            {
                user = ( UserAccount )_httpContext.Session[SessionHelper.UserData];
            }
            else
            {
                user = UserAccountServiceFacade.GetUserByName(_httpContext.User.Identity.Name);
            }

            if (user == null)
            {
                throw new InvalidOperationException("User is null");
            }

            /* parameter processing */
            if (!InputParameters.ContainsKey("DateFilter"))
            {
                throw new ArgumentException("DateFilter value was expected!");
            }

            var newDateFilterValue = ( GridDateFilter )Enum.Parse(typeof(GridDateFilter), InputParameters["DateFilter"].ToString());

            preApprovalListState.BoundDate = newDateFilterValue;

            // on date filter change, reset page number
            preApprovalListState.CurrentPage = 1;

            /* Command processing */
            FilterViewModel userFilterViewModel = null;

            if ((_httpContext != null) && (_httpContext.Session[SessionHelper.FilterViewModel] != null))
            {
                userFilterViewModel = new FilterViewModel().FromXml(_httpContext.Session[SessionHelper.FilterViewModel].ToString());
            }
            else
            {
                userFilterViewModel = new FilterViewModel();
            }

            preApprovalViewModel = PreApprovalDataHelper.RetrievePreApprovalViewModel(preApprovalListState,
                                                                                      _httpContext.Session[SessionHelper.UserAccountIds] != null
                                                                              ? (List <int>)
                                                                                      _httpContext.Session[SessionHelper.UserAccountIds]
                                                                              : new List <int> {
            },
                                                                                      user.UserAccountId, searchValue,
                                                                                      userFilterViewModel.CompanyId, userFilterViewModel.ChannelId, userFilterViewModel.DivisionId, userFilterViewModel.BranchId);

            _viewName  = "Queues/_preApproval";
            _viewModel = preApprovalViewModel;

            /* Persist new state */
            _httpContext.Session[SessionHelper.PreApprovalViewModel] = preApprovalViewModel.ToXml();
            _httpContext.Session[SessionHelper.PreApprovalListState] = preApprovalListState;
        }
        public void Execute()
        {
            String searchValue = CommonHelper.GetSearchValue(_httpContext);

            PreApprovalListState preApprovalListState = null;

            if ((_httpContext != null) && (_httpContext.Session[SessionHelper.PreApprovalListState] != null))
            {
                preApprovalListState = ( PreApprovalListState )_httpContext.Session[SessionHelper.PreApprovalListState];
            }
            else
            {
                preApprovalListState = new PreApprovalListState();
            }

            FilterViewModel userFilterViewModel = null;

            if ((_httpContext != null) && (_httpContext.Session[SessionHelper.FilterViewModel] != null))
            {
                userFilterViewModel = new FilterViewModel().FromXml(_httpContext.Session[SessionHelper.FilterViewModel].ToString());
                userFilterViewModel.FilterContext = FilterContextEnum.PreApproval;
            }
            else
            {
                // possible state retrieval?
                userFilterViewModel = new FilterViewModel
                {
                    FilterContext = FilterContextEnum.PreApproval
                };
            }

            Boolean refresh = InputParameters != null && InputParameters.ContainsKey("Refresh") && InputParameters["Refresh"].ToString().Trim() == "true";

            // reset Page Number to 1st on Tab change
            if (!refresh)
            {
                preApprovalListState.CurrentPage = 1;
            }

            UserAccount user = null;

            if (_httpContext.Session[SessionHelper.UserData] != null)
            {
                user = ( UserAccount )_httpContext.Session[SessionHelper.UserData];
            }
            else
            {
                throw new InvalidOperationException("UserData is null");
            }

            var preApprovalViewModel = new PreApprovalViewModel();

            preApprovalViewModel = PreApprovalDataHelper.RetrievePreApprovalViewModel(preApprovalListState,
                                                                                      _httpContext.Session[SessionHelper.UserAccountIds] != null
                                                              ? (List <int>)_httpContext.Session[SessionHelper.UserAccountIds]
                                                              : new List <int> {
            }, user.UserAccountId, searchValue,
                                                                                      userFilterViewModel.CompanyId, userFilterViewModel.ChannelId, userFilterViewModel.DivisionId, userFilterViewModel.BranchId);

            _viewName  = "Queues/_preapproval";
            _viewModel = preApprovalViewModel;

            /* Persist new state */
            _httpContext.Session[SessionHelper.PreApprovalViewModel] = preApprovalViewModel.ToXml();
            _httpContext.Session[SessionHelper.PreApprovalListState] = preApprovalListState;
            _httpContext.Session[SessionHelper.FilterViewModel]      = userFilterViewModel.ToXml();
            _httpContext.Session[SessionHelper.CurrentTab]           = LoanCenterTab.PreApproval;
        }
Beispiel #3
0
        /// <summary>
        /// Based on Type calls different methods for retreiving data
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="listState"></param>
        /// <param name="userAccounts"></param>
        /// <param name="userId"></param>
        /// <param name="searchValue"></param>
        /// <returns></returns>
        private object HandleRetrieveQueueLoans <T>(T listState, List <int> userAccounts, int userId, String searchValue)
        {
            FilterViewModel userFilterViewModel = null;

            if ((base.HttpContext != null) && (base.HttpContext.Session[SessionHelper.FilterViewModel] != null))
            {
                userFilterViewModel = new FilterViewModel().FromXml(base.HttpContext.Session[SessionHelper.FilterViewModel].ToString());
            }
            else
            {
                userFilterViewModel = new FilterViewModel();
            }

            if (listState is NewLoanApplicationListState)
            {
                return(( object )NewLoanApplicationDataHelper.RetrieveNewApplicationViewModel((listState as NewLoanApplicationListState), userAccounts, userId, userFilterViewModel.CompanyId, userFilterViewModel.ChannelId, userFilterViewModel.DivisionId, userFilterViewModel.BranchId, searchValue));
            }
            if (listState is OrderExceptionListState)
            {
                return(( object )OrderExceptionDataHelper.RetrieveOrderExceptionViewModel((listState as OrderExceptionListState), userAccounts, userId, userFilterViewModel.CompanyId, userFilterViewModel.ChannelId, userFilterViewModel.DivisionId, userFilterViewModel.BranchId, searchValue));
            }
            if (listState is OrderDeliveredForReviewListState)
            {
                return(( object )OrderDeliveredForReviewDataHelper.RetrieveOrderDeliveredForReviewViewModel((listState as OrderDeliveredForReviewListState), userAccounts, userId, userFilterViewModel.CompanyId, userFilterViewModel.ChannelId, userFilterViewModel.DivisionId, userFilterViewModel.BranchId, searchValue));
            }
            if (listState is OrderProcessedListState)
            {
                return(( object )OrderProcessedDataHelper.RetrieveOrderProcessedViewModel((listState as OrderProcessedListState), userAccounts, userId, userFilterViewModel.CompanyId, userFilterViewModel.ChannelId, userFilterViewModel.DivisionId, userFilterViewModel.BranchId, searchValue));
            }
            if (listState is OrderRequestedListState)
            {
                return(( object )OrderRequestedDataHelper.RetrieveOrderRequestedViewModel((listState as OrderRequestedListState), userAccounts, userId, userFilterViewModel.CompanyId, userFilterViewModel.ChannelId, userFilterViewModel.DivisionId, userFilterViewModel.BranchId, searchValue));
            }
            if (listState is CompletedLoansListState)
            {
                return(( object )CompletedLoansDataHelper.RetrieveCompletedLoansViewModel((listState as CompletedLoansListState), userAccounts, userId, searchValue, userFilterViewModel.CompanyId, userFilterViewModel.ChannelId, userFilterViewModel.DivisionId, userFilterViewModel.BranchId));
            }
            if (listState is CancelLoanListState)
            {
                return(( object )CancelDataHelper.RetrieveCancelViewModel((listState as CancelLoanListState), userAccounts,
                                                                          ((listState as CancelLoanListState)).BoundDate, userId, userFilterViewModel.CompanyId, userFilterViewModel.ChannelId, userFilterViewModel.DivisionId, userFilterViewModel.BranchId, searchValue));
            }
            if (listState is AlertsListState)
            {
                return(( object )AlertsDataHelper.RetrieveAlertViewModel((listState as AlertsListState), userAccounts,
                                                                         (listState as AlertsListState).BoundDate, userId, userFilterViewModel.CompanyId, userFilterViewModel.ChannelId, userFilterViewModel.DivisionId, userFilterViewModel.BranchId));
            }
            if (listState is PendingApprovalListState)
            {
                return(( object )PendingApprovalDataHelper.RetrievePendingApprovalViewModel((listState as PendingApprovalListState), userAccounts, userId, searchValue, userFilterViewModel.CompanyId, userFilterViewModel.ChannelId, userFilterViewModel.DivisionId, userFilterViewModel.BranchId
                                                                                            ));
            }
            if (listState is PreApprovalListState)
            {
                return(( object )PreApprovalDataHelper.RetrievePreApprovalViewModel((listState as PreApprovalListState), userAccounts, userId, searchValue, userFilterViewModel.CompanyId, userFilterViewModel.ChannelId, userFilterViewModel.DivisionId, userFilterViewModel.BranchId));
            }
            if (listState is PipelineListState)
            {
                return(( object )PipelineDataHelper.RetrievePipelineViewModel((listState as PipelineListState), userAccounts, userId, userFilterViewModel.CompanyId, userFilterViewModel.ChannelId, userFilterViewModel.DivisionId, userFilterViewModel.BranchId, searchValue));
            }

            if (listState is MailRoomListState)
            {
                return(( object )MailRoomDataHelper.RetrieveMailRoomViewModel((listState as MailRoomListState), userAccounts, userId, userFilterViewModel.CompanyId, userFilterViewModel.ChannelId, userFilterViewModel.DivisionId, userFilterViewModel.BranchId, searchValue));
            }

            return(null);
        }
        public void Execute()
        {
            String searchValue = CommonHelper.GetSearchValue(_httpContext);

            /* State retrieval */
            PreApprovalViewModel preApprovalViewModel = null;

            if (_httpContext.Session[SessionHelper.PreApprovalViewModel] != null)
            {
                preApprovalViewModel = new PreApprovalViewModel().FromXml(_httpContext.Session[SessionHelper.PreApprovalViewModel].ToString());
            }
            else
            {
                preApprovalViewModel = new PreApprovalViewModel();
            }

            PreApprovalListState preApprovalListState = null;

            if (_httpContext.Session[SessionHelper.PreApprovalListState] != null)
            {
                preApprovalListState = ( PreApprovalListState )_httpContext.Session[SessionHelper.PreApprovalListState];
            }
            else
            {
                preApprovalListState = new PreApprovalListState();
            }

            UserAccount user = null;

            if (_httpContext.Session[SessionHelper.UserData] != null && ((UserAccount)_httpContext.Session[SessionHelper.UserData]).Username == _httpContext.User.Identity.Name)
            {
                user = ( UserAccount )_httpContext.Session[SessionHelper.UserData];
            }
            else
            {
                user = UserAccountServiceFacade.GetUserByName(_httpContext.User.Identity.Name);
            }

            if (user == null)
            {
                throw new InvalidOperationException("User is null");
            }

            /* parameter processing */
            PreApprovalAttribute newSortColumn;

            if (!InputParameters.ContainsKey("Column"))
            {
                throw new ArgumentException("Column value was expected!");
            }
            else
            {
                newSortColumn = ( PreApprovalAttribute )Enum.Parse(typeof(PreApprovalAttribute), InputParameters["Column"].ToString());
            }

            // switch direction
            if (preApprovalListState.SortColumn == newSortColumn && preApprovalListState.SortDirection == "ASC")
            {
                preApprovalListState.SortDirection = "DESC";
            }
            else
            {
                preApprovalListState.SortDirection = "ASC";
            }

            preApprovalListState.SortColumn  = newSortColumn;
            preApprovalListState.CurrentPage = 1;

            /* Command processing */
            FilterViewModel userFilterViewModel = null;

            if ((_httpContext != null) && (_httpContext.Session[SessionHelper.FilterViewModel] != null))
            {
                userFilterViewModel = new FilterViewModel().FromXml(_httpContext.Session[SessionHelper.FilterViewModel].ToString());
            }
            else
            {
                userFilterViewModel = new FilterViewModel();
            }
            var preApprovalViewData = PreApprovalDataHelper.RetrievePreApprovalViewModel(preApprovalListState,
                                                                                         _httpContext.Session[SessionHelper.UserAccountIds] !=
                                                                                         null
                                                                                    ? (List <int>)
                                                                                         _httpContext.Session[
                                                                                             SessionHelper.UserAccountIds]
                                                                                    : new List <int> {
            },
                                                                                         user.UserAccountId, searchValue, userFilterViewModel.CompanyId, userFilterViewModel.ChannelId, userFilterViewModel.DivisionId, userFilterViewModel.BranchId);


            if (preApprovalViewModel != null)
            {
                preApprovalViewModel.PreApprovalItems = preApprovalViewData.PreApprovalItems;
                preApprovalViewModel.PageCount        = preApprovalViewData.PageCount;
                preApprovalViewModel.TotalItems       = preApprovalViewData.TotalItems;

                PreApprovalGridHelper.ProcessPagingOptions(preApprovalListState, preApprovalViewModel);
            }


            _viewName  = "Queues/_preapproval";
            _viewModel = preApprovalViewModel;

            /* Persist new state */
            _httpContext.Session[SessionHelper.PreApprovalViewModel] = preApprovalViewModel.ToXml();
            _httpContext.Session[SessionHelper.PreApprovalListState] = preApprovalListState;
        }