Exemplo n.º 1
0
        public questStatus List(QueryOptions queryOptions, out GroupsListViewModel groupsListViewModel)
        {
            // Initialize
            questStatus status = null;

            groupsListViewModel = null;


            // List
            QueryResponse queryResponse = null;
            List <Quest.Functional.ASM.Group> groupList = null;
            GroupsMgr groupsMgr = new GroupsMgr(this.UserSession);

            status = groupsMgr.List(queryOptions, out groupList, out queryResponse);
            if (!questStatusDef.IsSuccess(status))
            {
                return(status);
            }

            // Sort
            groupList.Sort(delegate(Quest.Functional.ASM.Group i1, Quest.Functional.ASM.Group i2) { return(i1.Name.CompareTo(i2.Name)); });


            // Transfer model.
            // TODO: USE BaseListModeler to xfer queryOptions to QueryOptionsViewModel.
            groupsListViewModel = new GroupsListViewModel(this.UserSession);
            QueryResponseViewModel queryResponseViewModel = null;

            status = TransferQueryResponse(queryResponse, out queryResponseViewModel);
            if (!questStatusDef.IsSuccess(status))
            {
                return(status);
            }
            groupsListViewModel.QueryResponse = queryResponseViewModel;
            foreach (Quest.Functional.ASM.Group group in groupList)
            {
                GroupLineItemViewModel groupLineItemViewModel = new GroupLineItemViewModel();
                BufferMgr.TransferBuffer(group, groupLineItemViewModel);
                groupsListViewModel.Items.Add(groupLineItemViewModel);
            }
            return(new questStatus(Severity.Success));
        }
Exemplo n.º 2
0
        public questStatus Page(out GroupsListViewModel groupsListViewModel)
        {
            // Initialize
            questStatus status = null;

            groupsListViewModel = 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.Group> groupList = null;
            GroupsMgr groupsMgr = new GroupsMgr(this.UserSession);

            status = groupsMgr.List(queryOptions, out groupList, out queryResponse);
            if (!questStatusDef.IsSuccess(status))
            {
                return(status);
            }

            // Transfer model.
            groupsListViewModel = new GroupsListViewModel(this.UserSession);
            foreach (Quest.Functional.ASM.Group group in groupList)
            {
                GroupLineItemViewModel groupLineItemViewModel = new GroupLineItemViewModel();
                BufferMgr.TransferBuffer(group, groupLineItemViewModel);
                groupsListViewModel.Items.Add(groupLineItemViewModel);
            }
            return(new questStatus(Severity.Success));
        }
Exemplo n.º 3
0
        /*==================================================================================================================================
        * Public Methods
        *=================================================================================================================================*/

        #region LOAD
        //----------------------------------------------------------------------------------------------------------------------------------
        // LOAD
        //----------------------------------------------------------------------------------------------------------------------------------
        public questStatus Load(out List <BootstrapTreenodeViewModel> groupNodeList)
        {
            // Initialize
            questStatus status = null;

            groupNodeList = 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();

            queryOptions.SearchOptions = searchOptions;
            QueryResponse queryResponse = null;


            // Get groups.
            List <Group> groupList = null;
            GroupsMgr    groupsMgr = new GroupsMgr(this.UserSession);

            status = groupsMgr.List(queryOptions, out groupList, out queryResponse);
            if (!questStatusDef.IsSuccess(status))
            {
                return(status);
            }

            // Transfer model
            groupNodeList = new List <BootstrapTreenodeViewModel>();
            foreach (Group group in groupList)
            {
                BootstrapTreenodeViewModel groupNode = null;
                FormatBootstrapTreeviewNode(group, out groupNode);
                groupNodeList.Add(groupNode);
            }
            return(new questStatus(Severity.Success));
        }
        public questStatus Read(UserGroupsViewModel viewModel, out UserGroupsViewModel userGroupsViewModel)
        {
            // Initialize
            questStatus status = null;

            userGroupsViewModel = 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 groups
            List <SearchField> searchFieldList = new List <SearchField>();
            SearchOptions      searchOptions   = new SearchOptions();

            searchOptions.SearchFieldList = searchFieldList;
            QueryOptions queryOptions = new QueryOptions();

            queryOptions.SearchOptions = searchOptions;
            QueryResponse queryResponse = null;

            List <Group> groupList = null;
            GroupsMgr    groupsMgr = new GroupsMgr(this.UserSession);

            status = groupsMgr.List(queryOptions, out groupList, out queryResponse);
            if (!questStatusDef.IsSuccess(status))
            {
                return(status);
            }


            // Get user groups
            List <Group> userGroupList = null;
            AccountMgr   accountMgr    = new AccountMgr(this.UserSession);

            status = accountMgr.GetUserGroups(userId, out userGroupList);
            if (!questStatusDef.IsSuccess(status))
            {
                return(status);
            }

            // Remove from groups lists whatever groups the user is already in.
            List <Group> unassignedGroupList = new List <Group>();

            foreach (Group group in groupList)
            {
                Group userGroup = userGroupList.Find(delegate(Group g) { return(g.Id == group.Id); });
                if (userGroup == null)
                {
                    unassignedGroupList.Add(group);
                }
            }

            // Sort group lists
            unassignedGroupList.Sort(delegate(Group i1, Group i2) { return(i1.Name.CompareTo(i2.Name)); });
            userGroupList.Sort(delegate(Group i1, Group i2) { return(i1.Name.CompareTo(i2.Name)); });


            // Transfer model
            userGroupsViewModel = new UserGroupsViewModel(this.UserSession, viewModel);
            UserEditorViewModel userEditorViewModel = new UserEditorViewModel();

            BufferMgr.TransferBuffer(user, userEditorViewModel);
            userGroupsViewModel.User = userEditorViewModel;
            foreach (Group group in unassignedGroupList)
            {
                BootstrapTreenodeViewModel groupNode = null;
                status = FormatBootstrapTreeviewNode(group, out groupNode);
                if (!questStatusDef.IsSuccess(status))
                {
                    return(status);
                }
                userGroupsViewModel.Groups.Add(groupNode);
            }
            foreach (Group group in userGroupList)
            {
                BootstrapTreenodeViewModel userGroupNode = null;
                status = FormatBootstrapTreeviewNode(group, out userGroupNode);
                if (!questStatusDef.IsSuccess(status))
                {
                    return(status);
                }
                userGroupsViewModel.UserGroups.Add(userGroupNode);
            }
            return(new questStatus(Severity.Success));
        }