Beispiel #1
0
        public override void Execute()
        {
            var searchValue = CommonHelper.GetSearchValue(base.HttpContext);

            FilterViewModel filterViewModel = null;

            if (base.HttpContext != null && base.HttpContext.Session[SessionHelper.FilterViewModel] != null)
            {
                filterViewModel = new FilterViewModel().FromXml(base.HttpContext.Session[SessionHelper.FilterViewModel].ToString());
                filterViewModel.FilterContext = Helpers.Enums.FilterContextEnum.OrderDeliveredForReview;
            }
            else
            {
                filterViewModel = new FilterViewModel();
                filterViewModel.FilterContext = Helpers.Enums.FilterContextEnum.OrderDeliveredForReview;
            }

            OrderDeliveredForReviewListState orderDeliveredForReviewListState;

            if (base.HttpContext.Session[SessionHelper.OrderDeliveredForReviewListState] != null)
            {
                orderDeliveredForReviewListState = ( OrderDeliveredForReviewListState )base.HttpContext.Session[SessionHelper.OrderDeliveredForReviewListState];
            }
            else
            {
                orderDeliveredForReviewListState = new OrderDeliveredForReviewListState();
            }

            UserAccount user;

            if (base.HttpContext.Session[SessionHelper.UserData] != null && (( UserAccount )base.HttpContext.Session[SessionHelper.UserData]).Username == base.HttpContext.User.Identity.Name)
            {
                user = ( UserAccount )base.HttpContext.Session[SessionHelper.UserData];
            }
            else
            {
                user = UserAccountServiceFacade.GetUserByName(base.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());

            orderDeliveredForReviewListState.BoundDate = newDateFilterValue;

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

            /* Command processing */
            OrderDeliveredForReviewViewModel orderDeliveredForReviewViewModel = OrderDeliveredForReviewDataHelper.RetrieveOrderDeliveredForReviewViewModel(orderDeliveredForReviewListState,
                                                                                                                                                           base.HttpContext.Session[SessionHelper.UserAccountIds] != null
                                                                              ? (List <int>)
                                                                                                                                                           base.HttpContext.Session[SessionHelper.UserAccountIds]
                                                                              : new List <int> {
            },
                                                                                                                                                           user.UserAccountId, filterViewModel.CompanyId, filterViewModel.ChannelId, filterViewModel.DivisionId, filterViewModel.BranchId, searchValue);

            ViewName = "Queues/_orderDeliveredForReview";
            ViewData = orderDeliveredForReviewViewModel;

            /* Persist new state */
            base.HttpContext.Session[SessionHelper.OrderDeliveredForReviewViewModel] = orderDeliveredForReviewViewModel.ToXml();
            base.HttpContext.Session[SessionHelper.OrderDeliveredForReviewListState] = orderDeliveredForReviewListState;
        }
        public override void Execute()
        {
            String serarchValue = CommonHelper.GetSearchValue(base.HttpContext);

            OrderDeliveredForReviewListState orderDeliveredForReviewListState = null;

            if (base.HttpContext != null && base.HttpContext.Session[SessionHelper.OrderDeliveredForReviewListState] != null)
            {
                orderDeliveredForReviewListState = ( OrderDeliveredForReviewListState )base.HttpContext.Session[SessionHelper.OrderDeliveredForReviewListState];
            }
            else
            {
                orderDeliveredForReviewListState = new OrderDeliveredForReviewListState();
            }

            FilterViewModel filterViewModel = null;

            if (base.HttpContext != null && base.HttpContext.Session[SessionHelper.FilterViewModel] != null)
            {
                filterViewModel = new FilterViewModel().FromXml(base.HttpContext.Session[SessionHelper.FilterViewModel].ToString());
                filterViewModel.FilterContext = Helpers.Enums.FilterContextEnum.OrderDeliveredForReview;
            }
            else
            {
                filterViewModel = new FilterViewModel();
                filterViewModel.FilterContext = Helpers.Enums.FilterContextEnum.OrderDeliveredForReview;
            }

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

            if (!refresh)
            {
                orderDeliveredForReviewListState.CurrentPage = 1;
            }

            UserAccount user = null;

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

            OrderDeliveredForReviewViewModel orderDeliveredForReviewViewModel = new OrderDeliveredForReviewViewModel();

            orderDeliveredForReviewViewModel = OrderDeliveredForReviewDataHelper.RetrieveOrderDeliveredForReviewViewModel(orderDeliveredForReviewListState,
                                                                                                                          base.HttpContext.Session[SessionHelper.UserAccountIds] != null
                            ? (List <int>)base.HttpContext.Session[SessionHelper.UserAccountIds]
                            : new List <int> {
            }, user.UserAccountId, filterViewModel.CompanyId, filterViewModel.ChannelId, filterViewModel.DivisionId, filterViewModel.BranchId, serarchValue);

            OrderDeliveredForReviewGridHelper.ProcessPagingOptions(orderDeliveredForReviewListState, orderDeliveredForReviewViewModel);
            OrderDeliveredForReviewGridHelper.ApplyClassCollection(orderDeliveredForReviewViewModel);

            ViewName = "Queues/_orderDeliveredForReview";
            ViewData = orderDeliveredForReviewViewModel;

            /* Persist new state */
            base.HttpContext.Session[SessionHelper.OrderDeliveredForReviewViewModel] = orderDeliveredForReviewViewModel.ToXml();
            base.HttpContext.Session[SessionHelper.OrderDeliveredForReviewListState] = orderDeliveredForReviewListState;
            base.HttpContext.Session[SessionHelper.FilterViewModel] = filterViewModel.ToXml();
            base.HttpContext.Session[SessionHelper.CurrentTab]      = LoanCenterTab.OrderDeliveredForReview;
        }