public questStatus Read(TypeListId typeListId, out TypeListEditorViewModel typeListEditorViewModel)
        {
            // Initialize
            questStatus status = null;

            typeListEditorViewModel = null;


            // Read
            Quest.Functional.MasterPricing.TypeList typeList = null;
            TypeListsMgr typeListsMgr = new TypeListsMgr(this.UserSession);

            status = typeListsMgr.Read(typeListId, out typeList);
            if (!questStatusDef.IsSuccess(status))
            {
                return(status);
            }

            // Transfer model.
            typeListEditorViewModel = new TypeListEditorViewModel(this.UserSession);
            BufferMgr.TransferBuffer(typeList, typeListEditorViewModel);



            return(new questStatus(Severity.Success));
        }
        public questStatus Delete(TypeListId typeListId)
        {
            // Initialize
            questStatus status = null;


            // Delete
            TypeListsMgr typeListsMgr = new TypeListsMgr(this.UserSession);

            status = typeListsMgr.Delete(typeListId);
            if (!questStatusDef.IsSuccess(status))
            {
                return(status);
            }
            return(new questStatus(Severity.Success));
        }
        public questStatus ListTypeLists(DatabaseId databaseId, out List <BootstrapTreenodeViewModel> typeListNodeList)
        {
            // Initialize
            questStatus status = null;

            typeListNodeList = null;


            // Set up query options.
            // TEMPORARY: OPTIMIZE THIS
            QueryOptions       queryOptions    = new QueryOptions();
            List <SearchField> searchFieldList = new List <SearchField>();
            SearchField        searchField     = new SearchField();

            searchField.Name            = "DatabaseId";
            searchField.SearchOperation = SearchOperation.Equal;
            searchField.Type            = typeof(int);
            searchField.Value           = databaseId.Id.ToString();
            searchFieldList.Add(searchField);
            SearchOptions searchOptions = new SearchOptions();

            searchOptions.SearchFieldList = searchFieldList;
            queryOptions.SearchOptions    = searchOptions;


            // Read typeLists
            TypeListsMgr    typeListsMgr  = new TypeListsMgr(this.UserSession);
            QueryResponse   queryResponse = null;
            List <TypeList> typeListList  = null;

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


            // Transfer model.
            typeListNodeList = new List <BootstrapTreenodeViewModel>();
            foreach (TypeList typeList in typeListList)
            {
                BootstrapTreenodeViewModel typeListNode = null;
                FormatBootstrapTreeviewNode(typeList, out typeListNode);
                typeListNodeList.Add(typeListNode);
            }
            return(new questStatus(Severity.Success));
        }
        public questStatus List(QueryOptions queryOptions, out TypeListsListViewModel typeListsListViewModel)
        {
            // Initialize
            questStatus status = null;

            typeListsListViewModel = null;


            // List
            QueryResponse queryResponse = null;
            List <Quest.Functional.MasterPricing.TypeList> typeListList = null;
            TypeListsMgr typeListsMgr = new TypeListsMgr(this.UserSession);

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

            // Sort
            typeListList.Sort(delegate(Quest.Functional.MasterPricing.TypeList i1, Quest.Functional.MasterPricing.TypeList i2) { return(i1.Name.CompareTo(i2.Name)); });


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

            status = TransferQueryResponse(queryResponse, out queryResponseViewModel);
            if (!questStatusDef.IsSuccess(status))
            {
                return(status);
            }
            typeListsListViewModel.QueryResponse = queryResponseViewModel;
            foreach (Quest.Functional.MasterPricing.TypeList typeList in typeListList)
            {
                TypeListLineItemViewModel typeListLineItemViewModel = new TypeListLineItemViewModel();
                BufferMgr.TransferBuffer(typeList, typeListLineItemViewModel);
                typeListsListViewModel.Items.Add(typeListLineItemViewModel);
            }
            return(new questStatus(Severity.Success));
        }
        public questStatus Page(out TypeListsListViewModel typeListsListViewModel)
        {
            // Initialize
            questStatus status = null;

            typeListsListViewModel = 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.MasterPricing.TypeList> typeListList = null;
            TypeListsMgr typeListsMgr = new TypeListsMgr(this.UserSession);

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

            // Transfer model.
            typeListsListViewModel = new TypeListsListViewModel(this.UserSession);
            foreach (Quest.Functional.MasterPricing.TypeList typeList in typeListList)
            {
                TypeListLineItemViewModel typeListLineItemViewModel = new TypeListLineItemViewModel();
                BufferMgr.TransferBuffer(typeList, typeListLineItemViewModel);
                typeListsListViewModel.Items.Add(typeListLineItemViewModel);
            }
            return(new questStatus(Severity.Success));
        }
        /*==================================================================================================================================
        * Public Methods
        *=================================================================================================================================*/

        #region CRUD
        //----------------------------------------------------------------------------------------------------------------------------------
        // CRUD
        //----------------------------------------------------------------------------------------------------------------------------------
        public questStatus Save(TypeListEditorViewModel typeListEditorViewModel)
        {
            // Initialize
            questStatus status = null;


            // Transfer model
            Quest.Functional.MasterPricing.TypeList typeList = new Functional.MasterPricing.TypeList();
            BufferMgr.TransferBuffer(typeListEditorViewModel, typeList);


            // Determine if this is a create or update
            TypeListsMgr typeListsMgr = new TypeListsMgr(this.UserSession);

            if (typeListEditorViewModel.Id < BaseId.VALID_ID)
            {
                // Create
                TypeListId typeListId = null;
                status = typeListsMgr.Create(typeList, out typeListId);
                if (!questStatusDef.IsSuccess(status))
                {
                    FormatErrorMessage(status, typeListEditorViewModel);
                    return(status);
                }
                typeListEditorViewModel.Id = typeListId.Id;
            }
            else
            {
                // Update
                status = typeListsMgr.Update(typeList);
                if (!questStatusDef.IsSuccess(status))
                {
                    FormatErrorMessage(status, typeListEditorViewModel);
                    return(status);
                }
            }
            return(new questStatus(Severity.Success));
        }