public questStatus List(QueryOptions queryOptions, out PrivilegesListViewModel privilegesListViewModel) { // Initialize questStatus status = null; privilegesListViewModel = null; // List QueryResponse queryResponse = null; List <Quest.Functional.ASM.Privilege> privilegeList = null; PrivilegesMgr privilegesMgr = new PrivilegesMgr(this.UserSession); status = privilegesMgr.List(queryOptions, out privilegeList, out queryResponse); if (!questStatusDef.IsSuccess(status)) { return(status); } // Sort privilegeList.Sort(delegate(Quest.Functional.ASM.Privilege i1, Quest.Functional.ASM.Privilege i2) { return(i1.Name.CompareTo(i2.Name)); }); // Transfer model. // TODO: USE BaseListModeler to xfer queryOptions to QueryOptionsViewModel. privilegesListViewModel = new PrivilegesListViewModel(this.UserSession); QueryResponseViewModel queryResponseViewModel = null; status = TransferQueryResponse(queryResponse, out queryResponseViewModel); if (!questStatusDef.IsSuccess(status)) { return(status); } privilegesListViewModel.QueryResponse = queryResponseViewModel; foreach (Quest.Functional.ASM.Privilege privilege in privilegeList) { PrivilegeLineItemViewModel privilegeLineItemViewModel = new PrivilegeLineItemViewModel(); BufferMgr.TransferBuffer(privilege, privilegeLineItemViewModel); privilegesListViewModel.Items.Add(privilegeLineItemViewModel); } return(new questStatus(Severity.Success)); }
public questStatus Page(out PrivilegesListViewModel privilegesListViewModel) { // Initialize questStatus status = null; privilegesListViewModel = null; // Set up query options. // TEMPORARY: OPTIMIZE THIS List <SearchField> searchFieldList = new List <SearchField>(); SearchOptions searchOptions = new SearchOptions(); searchOptions.SearchFieldList = searchFieldList; QueryOptions queryOptions = new QueryOptions(100, 1); queryOptions.SearchOptions = searchOptions; QueryResponse queryResponse = null; // List List <Quest.Functional.ASM.Privilege> privilegeList = null; PrivilegesMgr privilegesMgr = new PrivilegesMgr(this.UserSession); status = privilegesMgr.List(queryOptions, out privilegeList, out queryResponse); if (!questStatusDef.IsSuccess(status)) { return(status); } // Transfer model. privilegesListViewModel = new PrivilegesListViewModel(this.UserSession); foreach (Quest.Functional.ASM.Privilege privilege in privilegeList) { PrivilegeLineItemViewModel privilegeLineItemViewModel = new PrivilegeLineItemViewModel(); BufferMgr.TransferBuffer(privilege, privilegeLineItemViewModel); privilegesListViewModel.Items.Add(privilegeLineItemViewModel); } return(new questStatus(Severity.Success)); }
public questStatus Read(UserPrivilegesViewModel viewModel, out UserPrivilegesViewModel userPrivilegesViewModel) { // Initialize questStatus status = null; userPrivilegesViewModel = null; UserId userId = new UserId(viewModel.Id); // Get the user User user = null; UsersMgr usersMgr = new UsersMgr(this.UserSession); status = usersMgr.Read(userId, out user); if (!questStatusDef.IsSuccess(status)) { return(status); } // Get privileges List <SearchField> searchFieldList = new List <SearchField>(); SearchOptions searchOptions = new SearchOptions(); searchOptions.SearchFieldList = searchFieldList; QueryOptions queryOptions = new QueryOptions(); queryOptions.SearchOptions = searchOptions; QueryResponse queryResponse = null; List <Privilege> privilegeList = null; PrivilegesMgr privilegesMgr = new PrivilegesMgr(this.UserSession); status = privilegesMgr.List(queryOptions, out privilegeList, out queryResponse); if (!questStatusDef.IsSuccess(status)) { return(status); } // Get user privileges List <Privilege> userPrivilegeList = null; AccountMgr accountMgr = new AccountMgr(this.UserSession); status = accountMgr.GetUserPrivileges(userId, out userPrivilegeList); if (!questStatusDef.IsSuccess(status)) { return(status); } // Remove from privileges lists whatever privileges the user is already in. List <Privilege> unassignedPrivilegeList = new List <Privilege>(); foreach (Privilege privilege in privilegeList) { Privilege userPrivilege = userPrivilegeList.Find(delegate(Privilege g) { return(g.Id == privilege.Id); }); if (userPrivilege == null) { unassignedPrivilegeList.Add(privilege); } } // Sort privilege lists unassignedPrivilegeList.Sort(delegate(Privilege i1, Privilege i2) { return(i1.Name.CompareTo(i2.Name)); }); userPrivilegeList.Sort(delegate(Privilege i1, Privilege i2) { return(i1.Name.CompareTo(i2.Name)); }); // Transfer model userPrivilegesViewModel = new UserPrivilegesViewModel(this.UserSession, viewModel); UserEditorViewModel userEditorViewModel = new UserEditorViewModel(); BufferMgr.TransferBuffer(user, userEditorViewModel); userPrivilegesViewModel.User = userEditorViewModel; foreach (Privilege privilege in unassignedPrivilegeList) { BootstrapTreenodeViewModel privilegeNode = null; status = FormatBootstrapTreeviewNode(privilege, out privilegeNode); if (!questStatusDef.IsSuccess(status)) { return(status); } privilegeNode.icon = "fa fa-lock padding-right-20"; userPrivilegesViewModel.Privileges.Add(privilegeNode); } foreach (Privilege privilege in userPrivilegeList) { BootstrapTreenodeViewModel userPrivilegeNode = null; status = FormatBootstrapTreeviewNode(privilege, out userPrivilegeNode); if (!questStatusDef.IsSuccess(status)) { return(status); } userPrivilegeNode.icon = "fa fa-unlock padding-right-20"; userPrivilegesViewModel.UserPrivileges.Add(userPrivilegeNode); } return(new questStatus(Severity.Success)); }