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

            NewLoanApplicationListState newLoanApplicationListState = null;

            if ((_httpContext != null) && (_httpContext.Session[SessionHelper.NewLoanApplicationListState] != null))
            {
                newLoanApplicationListState = ( NewLoanApplicationListState )_httpContext.Session["NewLoanApplicationListState"];
            }
            else
            {
                newLoanApplicationListState = new NewLoanApplicationListState();
            }

            FilterViewModel userFilterViewModel = null;

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

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

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

            UserAccount user = null;

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

            NewLoanApplicationViewModel newLoanApplicationViewModel = new NewLoanApplicationViewModel();

            newLoanApplicationViewModel = NewLoanApplicationDataHelper.RetrieveNewApplicationViewModel(newLoanApplicationListState,
                                                                                                       _httpContext.Session[SessionHelper.UserAccountIds] != null
                                                              ? (List <int>)_httpContext.Session[SessionHelper.UserAccountIds]
                                                              : new List <int> {
            }, user.UserAccountId, userFilterViewModel.CompanyId, userFilterViewModel.ChannelId, userFilterViewModel.DivisionId, userFilterViewModel.BranchId, searchValue);


            _viewName  = "Queues/_newLoanApplication";
            _viewModel = newLoanApplicationViewModel;

            /* Persist new state */
            _httpContext.Session["NewLoanApplicationViewModel"] = newLoanApplicationViewModel.ToXml();
            _httpContext.Session["NewLoanApplicationListState"] = newLoanApplicationListState;
            _httpContext.Session["FilterViewModel"]             = userFilterViewModel.ToXml();
            _httpContext.Session["CurrentTab"] = LoanCenterTab.NewLoanApplication;
        }
Example #2
0
        public void Execute()
        {
            String searchValue = CommonHelper.GetSearchValue(_httpContext);
            /* State retrieval */
            NewLoanApplicationViewModel newLoanApplicationViewModel = null;

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

            NewLoanApplicationListState newLoanApplicationListState = null;

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

            if (!InputParameters.ContainsKey("LoanPurposeFilter"))
            {
                throw new ArgumentException("LoanPurposeFilter was expected!");
            }

            if (InputParameters["LoanPurposeFilter"].ToString() == "0")
            {
                newLoanApplicationListState.LoanPurposeFilter = "";
            }
            else
            {
                newLoanApplicationListState.LoanPurposeFilter = InputParameters["LoanPurposeFilter"].ToString();
            }

            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");
            }


            // on date filter change, reset page number
            FilterViewModel userFilterViewModel = null;

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

            newLoanApplicationViewModel = NewLoanApplicationDataHelper.RetrieveNewApplicationViewModel(newLoanApplicationListState,
                                                                                                       _httpContext.Session[SessionHelper.UserAccountIds] != null
                                                              ? (List <int>)_httpContext.Session[SessionHelper.UserAccountIds]
                                                              : new List <int> {
            }, user.UserAccountId, userFilterViewModel.CompanyId, userFilterViewModel.ChannelId, userFilterViewModel.DivisionId,
                                                                                                       userFilterViewModel.BranchId, searchValue);


            _viewName  = "Queues/_newLoanApplication";
            _viewModel = newLoanApplicationViewModel;

            /* Persist new state */
            _httpContext.Session[SessionHelper.NewLoanApplicationViewModel] = newLoanApplicationViewModel.ToXml();
            _httpContext.Session[SessionHelper.NewLoanApplicationListState] = newLoanApplicationListState;
        }
        public void Execute()
        {
            String searchValue = CommonHelper.GetSearchValue(_httpContext);

            /* State retrieval */
            NewLoanApplicationViewModel newLoanApplicationViewModel = null;

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

            NewLoanApplicationListState newLoanApplicationListState = null;

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

            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 */
            NewLoanApplicationAttribute newSortColumn;

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

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

            newLoanApplicationListState.SortColumn  = newSortColumn;
            newLoanApplicationListState.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();
            }

            newLoanApplicationViewModel = NewLoanApplicationDataHelper.RetrieveNewApplicationViewModel(newLoanApplicationListState,
                                                                                                       _httpContext.Session["UserAccountIds"] !=
                                                                                                       null
                                                                                    ? (List <int>)
                                                                                                       _httpContext.Session[
                                                                                                           "UserAccountIds"]
                                                                                    : new List <int> {
            },
                                                                                                       user.UserAccountId, userFilterViewModel.CompanyId, userFilterViewModel.ChannelId, userFilterViewModel.DivisionId, userFilterViewModel.BranchId, searchValue);

            _viewName  = "Queues/_newLoanApplication";
            _viewModel = newLoanApplicationViewModel;

            /* Persist new state */
            _httpContext.Session[SessionHelper.NewLoanApplicationViewModel] = newLoanApplicationViewModel.ToXml();
            _httpContext.Session[SessionHelper.NewLoanApplicationListState] = newLoanApplicationListState;
        }