private void RetrieveTasks(UserAccount user, List <int> newUserAccountIds) { OfficerTaskListState officerTaskListState = new OfficerTaskListState(); if (base.HttpContext.Session[SessionHelper.OfficerTaskListState] != null) { officerTaskListState = ( OfficerTaskListState )base.HttpContext.Session[SessionHelper.OfficerTaskListState]; } // reset page to 1st on user change officerTaskListState.CurrentPage = 1; var result = TaskServiceFacade.GetTasks(newUserAccountIds, officerTaskListState.BoundDate, officerTaskListState.CurrentPage, officerTaskListState.SortColumn.GetStringValue(), officerTaskListState.SortDirection, user.UserAccountId ); OfficerTasksViewModel taskViewModel = new OfficerTasksViewModel { TaskOwners = PopulateTaskOwners() }; if (result != null) { taskViewModel.OfficerTasks = result.OfficerTasks; taskViewModel.PageCount = result.TotalPages; taskViewModel.TotalItems = result.TotalItems; taskViewModel.CurrentPage = officerTaskListState.CurrentPage; } OfficerTaskGridHelper.ProcessPagingOptions(officerTaskListState, taskViewModel); ApplyClassCollection(taskViewModel); base.ViewName = "_officertask"; base.ViewData = taskViewModel; /* Persist new state */ base.HttpContext.Session[SessionHelper.OfficerTaskListState] = officerTaskListState; base.HttpContext.Session[SessionHelper.OfficerTaskViewModel] = taskViewModel.ToXml(); }
public void Execute() { /* State retrieval */ OfficerTasksViewModel taskViewModel = null; if (_httpContext.Session["OfficerTaskViewModel"] != null) { taskViewModel = new OfficerTasksViewModel().FromXml(_httpContext.Session["OfficerTaskViewModel"].ToString()); } else { taskViewModel = new OfficerTasksViewModel(); } OfficerTaskListState taskListState = null; if (_httpContext.Session["OfficerTaskListState"] != null) { taskListState = (OfficerTaskListState)_httpContext.Session["OfficerTaskListState"]; } else { taskListState = new OfficerTaskListState(); } 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 */ OfficerTaskAttribute newSortColumn; if (!InputParameters.ContainsKey("Column")) { throw new ArgumentException("Column value was expected!"); } else { newSortColumn = (OfficerTaskAttribute)Enum.Parse(typeof(OfficerTaskAttribute), InputParameters["Column"].ToString()); } if (taskListState.SortColumn == newSortColumn) { // switch direction if (taskListState.SortDirection == "DESC") { taskListState.SortDirection = "ASC"; } else { taskListState.SortDirection = "DESC"; } } taskListState.SortColumn = newSortColumn; /* Command processing */ var result = TaskServiceFacade.GetTasks(_httpContext.Session[SessionHelper.UserAccountIds] != null ? (List <int>)_httpContext.Session[SessionHelper.UserAccountIds] : new List <int> { }, taskListState.BoundDate, taskListState.CurrentPage, EnumHelper.GetStringValue(taskListState.SortColumn), taskListState.SortDirection, user.UserAccountId ); if (result != null) { taskViewModel.OfficerTasks = result.OfficerTasks; taskViewModel.PageCount = result.TotalPages; taskViewModel.TotalItems = result.TotalItems; } OfficerTaskGridHelper.ProcessPagingOptions(taskListState, taskViewModel); OfficerTaskGridHelper.ApplyClassCollection(taskViewModel); _viewName = "_officertask"; _viewModel = taskViewModel; /* Persist new state */ _httpContext.Session["OfficerTaskViewModel"] = taskViewModel.ToXml(); _httpContext.Session["OfficerTaskListState"] = taskListState; }
public void Execute() { /* State retrieval */ UserAccount user = null; if (_httpContext.Session[SessionHelper.UserData] != null) { user = ( UserAccount )_httpContext.Session[SessionHelper.UserData]; } else { throw new InvalidOperationException("UserData is null"); } OfficerTasksViewModel taskViewModel = null; if (_httpContext.Session["OfficerTaskViewModel"] != null) { taskViewModel = new OfficerTasksViewModel().FromXml(_httpContext.Session["OfficerTaskViewModel"].ToString()); } else { taskViewModel = new OfficerTasksViewModel(); } OfficerTaskListState taskListState = null; if (_httpContext.Session["OfficerTaskListState"] != null) { taskListState = ( OfficerTaskListState )_httpContext.Session["OfficerTaskListState"]; } else { taskListState = new OfficerTaskListState(); } // Generate list of user account for retrieveing Tasks since this is the command that loads Task grid for the first time List <int> userAccountIds = PopulateUserAccountIdsByUserRole(user); var result = TaskServiceFacade.GetTasks(userAccountIds, taskListState.BoundDate, taskListState.CurrentPage, EnumHelper.GetStringValue(taskListState.SortColumn), taskListState.SortDirection, user.UserAccountId ); taskViewModel.TaskOwners = PopulateTaskOwners(); if (result != null) { taskViewModel.OfficerTasks = result.OfficerTasks; taskViewModel.PageCount = result.TotalPages; taskViewModel.TotalItems = result.TotalItems; taskViewModel.CurrentPage = taskListState.CurrentPage; } OfficerTaskGridHelper.ProcessPagingOptions(taskListState, taskViewModel); OfficerTaskGridHelper.ApplyClassCollection(taskViewModel); _viewName = "_officertask"; _viewModel = taskViewModel; /* Persist new state */ _httpContext.Session["OfficerTaskViewModel"] = taskViewModel.ToXml(); _httpContext.Session["OfficerTaskListState"] = taskListState; _httpContext.Session["UserAccountIds"] = userAccountIds; _httpContext.Session["CurrentTab"] = LoanCenterTab.OfficerTask; }
public void Execute() { OfficerTasksViewModel taskViewModel = null; if (_httpContext.Session["OfficerTaskViewModel"] != null) { taskViewModel = new OfficerTasksViewModel().FromXml(_httpContext.Session["OfficerTaskViewModel"].ToString()); } else { taskViewModel = new OfficerTasksViewModel(); } OfficerTaskListState taskListState = null; if ((_httpContext != null) && (_httpContext.Session["OfficerTaskListState"] != null)) { taskListState = (OfficerTaskListState)_httpContext.Session["OfficerTaskListState"]; } else { taskListState = new OfficerTaskListState(); } FilterViewModel userFilterViewModel = null; if ((_httpContext != null) && (_httpContext.Session["FilterViewModel"] != null)) { userFilterViewModel = new FilterViewModel().FromXml(_httpContext.Session["FilterViewModel"].ToString()); userFilterViewModel.FilterContext = Helpers.Enums.FilterContextEnum.OfficerTask; } else { // possible state retrieval? userFilterViewModel = new FilterViewModel(); userFilterViewModel.FilterContext = Helpers.Enums.FilterContextEnum.OfficerTask; } // reset Page Number to 1st on Tab change taskListState.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 result = TaskServiceFacade.GetTasks(_httpContext.Session[SessionHelper.UserAccountIds] != null ? (List <int>)_httpContext.Session[SessionHelper.UserAccountIds] : new List <int> { }, taskListState.BoundDate, taskListState.CurrentPage, EnumHelper.GetStringValue(taskListState.SortColumn), taskListState.SortDirection, user.UserAccountId ); if (result != null) { taskViewModel.OfficerTasks = result.OfficerTasks; taskViewModel.PageCount = result.TotalPages; taskViewModel.TotalItems = result.TotalItems; taskViewModel.CurrentPage = taskListState.CurrentPage; } OfficerTaskGridHelper.ProcessPagingOptions(taskListState, taskViewModel); OfficerTaskGridHelper.ApplyClassCollection(taskViewModel); _viewName = "_officertask"; _viewModel = taskViewModel; /* Persist new state */ _httpContext.Session["OfficerTaskViewModel"] = taskViewModel.ToXml(); _httpContext.Session["OfficerTaskListState"] = taskListState; _httpContext.Session["FilterViewModel"] = userFilterViewModel.ToXml(); _httpContext.Session["CurrentTab"] = LoanCenterTab.OfficerTask; }