Ejemplo n.º 1
0
        /*----------------------------------------------------------------------------------------------------------------------------------
        * FilterFolders
        *---------------------------------------------------------------------------------------------------------------------------------*/
        private questStatus create(MasterPricingEntities dbContext, Quest.Functional.MasterPricing.FilterFolder filterFolder, out FilterFolderId filterFolderId)
        {
            // Initialize
            filterFolderId = null;


            // Perform create
            try
            {
                Quest.Services.Dbio.MasterPricing.FilterFolders _filterFolders = new Quest.Services.Dbio.MasterPricing.FilterFolders();
                BufferMgr.TransferBuffer(filterFolder, _filterFolders);
                dbContext.FilterFolders.Add(_filterFolders);
                dbContext.SaveChanges();
                if (_filterFolders.Id == 0)
                {
                    return(new questStatus(Severity.Error, "Quest.Functional.MasterPricing.FilterFolder not created"));
                }
                filterFolderId = new FilterFolderId(_filterFolders.Id);
            }
            catch (System.Exception ex)
            {
                return(new questStatus(Severity.Fatal, String.Format("EXCEPTION: {0}.{1}: {2}",
                                                                     this.GetType().Name, MethodBase.GetCurrentMethod().Name,
                                                                     ex.InnerException != null ? ex.InnerException.Message : ex.Message)));
            }
            return(new questStatus(Severity.Success));
        }
        public questStatus Delete(FilterFolderViewModel filterFolderViewModel)
        {
            // Initialize
            questStatus status = null;



            // Delete the folder
            ////FilterFolderId filterFolderId = new FilterFolderId(filterFolderViewModel.Id);
            ////FilterFoldersMgr filterFoldersMgr = new FilterFoldersMgr(this.UserSession);
            ////status = filterFoldersMgr.Delete(filterFolderId);
            ////if (!questStatusDef.IsSuccess(status))
            ////{
            ////    FormatErrorMessage(status, filterFolderViewModel);
            ////    return (status);
            ////}


            FilterFolderId filterFolderId = new FilterFolderId(filterFolderViewModel.Id);
            FolderMgr      folderMgr      = new FolderMgr(this.UserSession);

            status = folderMgr.Delete(filterFolderId);
            if (!questStatusDef.IsSuccess(status))
            {
                FormatErrorMessage(status, filterFolderViewModel);
                return(status);
            }
            return(new questStatus(Severity.Success));
        }
Ejemplo n.º 3
0
        private questStatus update(MasterPricingEntities dbContext, Quest.Functional.MasterPricing.FilterFolder filterFolder)
        {
            // Initialize
            questStatus status = null;


            try
            {
                // Read the record.
                FilterFolderId filterFolderId = new FilterFolderId(filterFolder.Id);
                Quest.Services.Dbio.MasterPricing.FilterFolders _filterFolders = null;
                status = read(dbContext, filterFolderId, out _filterFolders);
                if (!questStatusDef.IsSuccess(status))
                {
                    return(status);
                }

                // Update the record.
                BufferMgr.TransferBuffer(filterFolder, _filterFolders);
                dbContext.SaveChanges();
            }
            catch (System.Exception ex)
            {
                return(new questStatus(Severity.Fatal, String.Format("EXCEPTION: {0}.{1}: {2}",
                                                                     this.GetType().Name, MethodBase.GetCurrentMethod().Name,
                                                                     ex.InnerException != null ? ex.InnerException.Message : ex.Message)));
            }
            return(new questStatus(Severity.Success));
        }
        public questStatus Delete(DbMgrTransaction trans, FilterFolderId filterFolderId)
        {
            // Initialize
            questStatus status = null;


            // Delete filterFolder
            status = _dbFilterFoldersMgr.Delete(trans, filterFolderId);
            if (!questStatusDef.IsSuccess(status))
            {
                return(status);
            }
            return(new questStatus(Severity.Success));
        }
Ejemplo n.º 5
0
 private questStatus delete(MasterPricingEntities dbContext, FilterFolderId filterFolderId)
 {
     try
     {
         dbContext.FilterFolders.RemoveRange(dbContext.FilterFolders.Where(r => r.Id == filterFolderId.Id));
         dbContext.SaveChanges();
     }
     catch (System.Exception ex)
     {
         return(new questStatus(Severity.Fatal, String.Format("EXCEPTION: {0}.{1}: {2}",
                                                              this.GetType().Name, MethodBase.GetCurrentMethod().Name,
                                                              ex.InnerException != null ? ex.InnerException.Message : ex.Message)));
     }
     return(new questStatus(Severity.Success));
 }
        public questStatus Delete(FilterFolderId filterFolderId)
        {
            // Initialize
            questStatus status = null;

            // Delete filterFolder
            DbFilterFoldersMgr dbFilterFoldesrMgr = new DbFilterFoldersMgr(this.UserSession);

            status = dbFilterFoldesrMgr.Delete(filterFolderId);
            if (!questStatusDef.IsSuccess(status))
            {
                return(status);
            }
            return(new questStatus(Severity.Success));
        }
Ejemplo n.º 7
0
        public questStatus Delete(DbMgrTransaction trans, FilterFolderId filterFolderId)
        {
            // Initialize
            questStatus status = null;


            // Perform delete in this transaction.
            status = delete((MasterPricingEntities)trans.DbContext, filterFolderId);
            if (!questStatusDef.IsSuccess(status))
            {
                RollbackTransaction(trans);
                return(status);
            }
            return(new questStatus(Severity.Success));
        }
        /*==================================================================================================================================
        * Properties
        *=================================================================================================================================*/
        #endregion


        #region Public Methods

        /*==================================================================================================================================
        * Public Methods
        *=================================================================================================================================*/
        public questStatus Create(FilterFolder filterFolder, out FilterFolderId filterFolderId)
        {
            // Initialize
            questStatus status = null;

            filterFolderId = null;


            // Create filterFolder
            status = _dbFilterFoldersMgr.Create(filterFolder, out filterFolderId);
            if (!questStatusDef.IsSuccess(status))
            {
                return(status);
            }
            return(new questStatus(Severity.Success));
        }
        public questStatus Read(DbMgrTransaction trans, FilterFolderId filterFolderId, out FilterFolder filterFolder)
        {
            // Initialize
            questStatus status = null;

            filterFolder = null;


            // Read filterFolder
            status = _dbFilterFoldersMgr.Read(trans, filterFolderId, out filterFolder);
            if (!questStatusDef.IsSuccess(status))
            {
                return(status);
            }
            return(new questStatus(Severity.Success));
        }
Ejemplo n.º 10
0
        public questStatus Delete(FilterFolderId filterFolderId)
        {
            // Initialize
            questStatus status = null;


            // Perform delete.
            using (MasterPricingEntities dbContext = new MasterPricingEntities())
            {
                status = delete(dbContext, filterFolderId);
                if (!questStatusDef.IsSuccess(status))
                {
                    return(status);
                }
            }
            return(new questStatus(Severity.Success));
        }
        /*==================================================================================================================================
        * Public Methods
        *=================================================================================================================================*/
        public questStatus Save(FilterFolderViewModel filterFolderViewModel)
        {
            // Initialize
            questStatus status = null;


            // Transfer model
            Quest.Functional.MasterPricing.FilterFolder filterFolder = new Functional.MasterPricing.FilterFolder();
            BufferMgr.TransferBuffer(filterFolderViewModel, filterFolder, true);
            if (filterFolderViewModel.FolderId < BaseId.VALID_ID)
            {
                filterFolder.FolderId = null;
            }


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

            if (filterFolderViewModel.Id < BaseId.VALID_ID)
            {
                // Create
                FilterFolderId filterFolderId = null;
                status = filterFoldersMgr.Create(filterFolder, out filterFolderId);
                if (!questStatusDef.IsSuccess(status))
                {
                    FormatErrorMessage(status, filterFolderViewModel);
                    return(status);
                }
                filterFolderViewModel.Id = filterFolderId.Id;
            }
            else
            {
                // Update
                status = filterFoldersMgr.Update(filterFolder);
                if (!questStatusDef.IsSuccess(status))
                {
                    FormatErrorMessage(status, filterFolderViewModel);
                    return(status);
                }
            }
            return(new questStatus(Severity.Success));
        }
Ejemplo n.º 12
0
        public questStatus Read(DbMgrTransaction trans, FilterFolderId filterFolderId, out Quest.Functional.MasterPricing.FilterFolder filterFolder)
        {
            // Initialize
            questStatus status = null;

            filterFolder = null;


            // Perform read
            Quest.Services.Dbio.MasterPricing.FilterFolders _filterFolders = null;
            status = read((MasterPricingEntities)trans.DbContext, filterFolderId, out _filterFolders);
            if (!questStatusDef.IsSuccess(status))
            {
                return(status);
            }
            filterFolder = new Quest.Functional.MasterPricing.FilterFolder();
            BufferMgr.TransferBuffer(_filterFolders, filterFolder);

            return(new questStatus(Severity.Success));
        }
Ejemplo n.º 13
0
        private questStatus clearFolder(DbMgrTransaction trans, List <FilterFolder> filterFolderList)
        {
            // Initialize
            questStatus status = null;


            // Navigate to bottom of folder hierarchy...
            foreach (FilterFolder filterFolder in filterFolderList)
            {
                status = clearFolder(trans, filterFolder.Folders);
                if (!questStatusDef.IsSuccess(status))
                {
                    return(status);
                }

                // Delete filters in the folder.
                foreach (Filter filter in filterFolder.Filters)
                {
                    FilterId filterId = new FilterId(filter.Id);
                    status = _dbFolderMgr.DeleteFilter(filterId);
                    if (!questStatusDef.IsSuccess(status))
                    {
                        return(status);
                    }
                }

                // Delete the folder.
                FilterFolderId filterFolderId = new FilterFolderId(filterFolder.Id);
                status = _filterFoldersMgr.Delete(trans, filterFolderId);
                if (!questStatusDef.IsSuccess(status))
                {
                    return(status);
                }
            }
            return(new questStatus(Severity.Success));
        }
Ejemplo n.º 14
0
        private questStatus read(MasterPricingEntities dbContext, FilterFolderId filterFolderId, out Quest.Services.Dbio.MasterPricing.FilterFolders filterFolder)
        {
            // Initialize
            filterFolder = null;


            try
            {
                filterFolder = dbContext.FilterFolders.Where(r => r.Id == filterFolderId.Id).SingleOrDefault();
                if (filterFolder == null)
                {
                    return(new questStatus(Severity.Error, String.Format("ERROR: {0}.{1}: {2}",
                                                                         this.GetType().Name, MethodBase.GetCurrentMethod().Name,
                                                                         String.Format("FilterFolderId {0} not found", filterFolderId.Id))));
                }
            }
            catch (System.Exception ex)
            {
                return(new questStatus(Severity.Fatal, String.Format("EXCEPTION: {0}.{1}: {2}",
                                                                     this.GetType().Name, MethodBase.GetCurrentMethod().Name,
                                                                     ex.InnerException != null ? ex.InnerException.Message : ex.Message)));
            }
            return(new questStatus(Severity.Success));
        }
Ejemplo n.º 15
0
        /*==================================================================================================================================
        * Public Methods
        *=================================================================================================================================*/
        public questStatus Delete(FilterFolderId filterFolderId)
        {
            // Initialize
            questStatus      status = null;
            DbMgrTransaction trans  = null;
            Mgr mgr = new Mgr(this.UserSession);

            try
            {
                // BEGIN TRANSACTION
                status = mgr.BeginTransaction("DeleteFolder_" + filterFolderId.Id.ToString() + "_" + Guid.NewGuid().ToString(), out trans);
                if (!questStatusDef.IsSuccess(status))
                {
                    return(status);
                }

                // Load folder contents
                FolderId            folderId         = new FolderId(filterFolderId.Id);
                List <FilterFolder> filterFolderList = null;
                FilterFoldersMgr    filterFoldersMgr = new FilterFoldersMgr(this.UserSession);
                status = filterFoldersMgr.Load(folderId, out filterFolderList);
                if (!questStatusDef.IsSuccess(status))
                {
                    mgr.RollbackTransaction(trans);
                    return(status);
                }

                // Clear out the folder
                status = clearFolder(trans, filterFolderList);
                if (!questStatusDef.IsSuccess(status))
                {
                    mgr.RollbackTransaction(trans);
                    return(status);
                }

                // Get fitlers in this folder.
                List <Quest.Functional.MasterPricing.Filter> filterList = null;
                FiltersMgr filtersMgr = new FiltersMgr(this.UserSession);
                status = filtersMgr.Read(folderId, out filterList);
                if (!questStatusDef.IsSuccess(status))
                {
                    mgr.RollbackTransaction(trans);
                    return(status);
                }

                // Delete filters in this folder
                foreach (Filter filter in filterList)
                {
                    FilterId filterId = new FilterId(filter.Id);
                    status = _dbFolderMgr.DeleteFilter(filterId);
                    if (!questStatusDef.IsSuccess(status))
                    {
                        return(status);
                    }
                }

                // Delete the folder.
                status = _filterFoldersMgr.Delete(trans, filterFolderId);
                if (!questStatusDef.IsSuccess(status))
                {
                    mgr.RollbackTransaction(trans);
                    return(status);
                }

                // COMMIT TRANSACTION
                status = mgr.CommitTransaction(trans);
                if (!questStatusDef.IsSuccess(status))
                {
                    return(status);
                }
            }
            catch (System.Exception ex)
            {
                if (trans != null)
                {
                    mgr.RollbackTransaction(trans);
                }
                return(new questStatus(Severity.Fatal, String.Format("EXCEPTION: {0}.{1}: {2}",
                                                                     this.GetType().Name, MethodBase.GetCurrentMethod().Name,
                                                                     ex.InnerException != null ? ex.InnerException.Message : ex.Message)));
            }
            return(new questStatus(Severity.Success));
        }
Ejemplo n.º 16
0
        public questStatus Create(DbMgrTransaction trans, Quest.Functional.MasterPricing.FilterFolder filterFolder, out FilterFolderId filterFolderId)
        {
            // Initialize
            questStatus status = null;

            filterFolderId = null;


            // Data rules.


            // Create the filterFolder in this transaction.
            status = create((MasterPricingEntities)trans.DbContext, filterFolder, out filterFolderId);
            if (!questStatusDef.IsSuccess(status))
            {
                return(status);
            }
            return(new questStatus(Severity.Success));
        }
Ejemplo n.º 17
0
        /*==================================================================================================================================
        * Properties
        *=================================================================================================================================*/
        #endregion


        #region Public Methods

        /*==================================================================================================================================
        * Public Methods
        *=================================================================================================================================*/
        public questStatus Create(Quest.Functional.MasterPricing.FilterFolder filterFolder, out FilterFolderId filterFolderId)
        {
            // Initialize
            questStatus status = null;

            filterFolderId = null;


            // Data rules.


            // Create the filterFolder
            using (MasterPricingEntities dbContext = new MasterPricingEntities())
            {
                status = create(dbContext, filterFolder, out filterFolderId);
                if (!questStatusDef.IsSuccess(status))
                {
                    return(status);
                }
            }
            return(new questStatus(Severity.Success));
        }