public static void ApplyClassCollection(PreApprovalViewModel preApprovalViewModel) { if (preApprovalViewModel.PreApprovalItems != null) { // Business rule foreach (var item in preApprovalViewModel.PreApprovalItems) { foreach (var preApprovalItem in item.PreApprovalViewItems) { preApprovalItem.ClassCollection = "preapprovaltablelist"; if (preApprovalItem.ExceptionItemMaxWeight != -1) { preApprovalItem.ExceptionClassCollection = preApprovalItem.ExceptionItemMaxWeight < 300 ? "exceptionIcon exceptionIcon0" : "exceptionIcon exceptionIcon1"; } if (preApprovalItem == item.PreApprovalViewItems.First()) { preApprovalItem.ClassCollection = preApprovalItem.ClassCollection + " first last"; } if (preApprovalItem == item.PreApprovalViewItems.Last()) { preApprovalItem.ClassCollection = preApprovalItem.ClassCollection + " last"; } } } } }
public static PreApprovalViewModel RetrievePreApprovalViewModel(PreApprovalListState preApprovalListState, List <int> userAccountIds, int userAccountId, string searchTerm, Guid companyId, int channelId, int divisionId, Guid branchId) { if (preApprovalListState == null) { preApprovalListState = new PreApprovalListState(); } if (userAccountIds == null) { userAccountIds = new List <int>(); } PreApprovalViewData preApprovalViewData = LoanServiceFacade.RetrievePreApprovalItemsView(userAccountIds, preApprovalListState.CurrentPage, preApprovalListState.SortColumn.GetStringValue(), preApprovalListState.SortDirection, preApprovalListState.BoundDate, userAccountId, searchTerm, companyId, channelId, divisionId, branchId ); if (preApprovalViewData == null) { preApprovalViewData = new PreApprovalViewData { PreApprovalViewItem = new List <PreApprovalViewItem>(), TotalItems = 0, TotalPages = 0 }; } PreApprovalViewModel preApprovalViewModel = new PreApprovalViewModel { ActivityTypeList = new List <ActivityType>(Enum.GetValues(typeof(ActivityType)).Cast <ActivityType>()), PreApprovalItems = preApprovalViewData.PreApprovalViewItem, PageCount = preApprovalViewData.TotalPages, TotalItems = preApprovalViewData.TotalItems }; PreApprovalGridHelper.ProcessPagingOptions(preApprovalListState, preApprovalViewModel); PreApprovalGridHelper.ApplyClassCollection(preApprovalViewModel); return(preApprovalViewModel); }
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; }
public static void ProcessPagingOptions(PreApprovalListState preApprovalListState, PreApprovalViewModel preApprovalViewModel) { if (preApprovalViewModel.PageCount % 10 == 0) { preApprovalViewModel.PageGroups = (preApprovalViewModel.PageCount / 10); } else { preApprovalViewModel.PageGroups = (preApprovalViewModel.PageCount / 10) + 1; } preApprovalViewModel.PageGroups = ( int )preApprovalViewModel.PageGroups; if (preApprovalViewModel.PageCount % 10 != 0) { preApprovalViewModel.LastPageItems = preApprovalViewModel.PageCount % 10; } else { preApprovalViewModel.LastPageItems = 10; } preApprovalViewModel.CurrentPage = preApprovalListState.CurrentPage; if (preApprovalViewModel.CurrentPage % 10 != 0) { preApprovalViewModel.StartPage = ( int )(preApprovalViewModel.CurrentPage / 10) * 10 + 1; if ((( int )((preApprovalViewModel.CurrentPage) / 10) + 1) == preApprovalViewModel.PageGroups) { preApprovalViewModel.EndPage = ( int )(preApprovalViewModel.CurrentPage / 10) * 10 + preApprovalViewModel.LastPageItems; preApprovalViewModel.LastPageDots = true; } else { preApprovalViewModel.EndPage = ( int )(preApprovalViewModel.CurrentPage / 10) * 10 + 10; preApprovalViewModel.LastPageDots = false; } } else { preApprovalViewModel.StartPage = ( int )((preApprovalViewModel.CurrentPage - 1) / 10) * 10 + 1; if ((( int )((preApprovalViewModel.CurrentPage - 1) / 10) + 1) == preApprovalViewModel.PageGroups) { preApprovalViewModel.EndPage = ( int )(preApprovalViewModel.CurrentPage / 10) * 10; preApprovalViewModel.LastPageDots = true; } else { preApprovalViewModel.EndPage = ( int )((preApprovalViewModel.CurrentPage - 1) / 10) * 10 + 10; preApprovalViewModel.LastPageDots = false; } } }
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; }