private questStatus delete(MasterPricingEntities dbContext, Quest.Functional.MasterPricing.DatabaseId databaseId)
        {
            // Initialize
            questStatus status = null;


            try
            {
                // Read the record.
                Quest.Services.Dbio.MasterPricing.Databases _database = null;
                status = read(dbContext, databaseId, out _database);
                if (!questStatusDef.IsSuccess(status))
                {
                    if (bLogging)
                    {
                        DatabaseLog databaseLog = new DatabaseLog();
                        databaseLog.Name  = "Database.Id=" + databaseId.Id;
                        databaseLog.Event = "DELETE";
                        databaseLog.Data  = status.ToString();
                        DatabaseLogId databaseLogId = null;
                        _dbDatabaseLogsMgr.Create(databaseLog, out databaseLogId);
                    }
                    return(status);
                }

                // Delete the record.
                dbContext.Databases.Remove(_database);
                dbContext.SaveChanges();
            }
            catch (DbEntityValidationException ex)
            {
                var    errorMessages    = ex.EntityValidationErrors.SelectMany(x => x.ValidationErrors).Select(x => x.ErrorMessage);
                String fullErrorMessage = string.Join("; ", errorMessages);
                String exceptionMessage = string.Concat(ex.Message, fullErrorMessage);
                status = new questStatus(Severity.Fatal, String.Format("EXCEPTION: {0}.{1}: {2}",
                                                                       this.GetType().Name, MethodBase.GetCurrentMethod().Name,
                                                                       exceptionMessage));
                LogException(ex, status);
                return(status);
            }
            catch (System.Exception ex)
            {
                status = new questStatus(Severity.Fatal, String.Format("EXCEPTION: {0}.{1}: {2}",
                                                                       this.GetType().Name, MethodBase.GetCurrentMethod().Name,
                                                                       ex.InnerException != null ? ex.InnerException.Message : ex.Message));
                LogException(ex, status);
                return(status);
            }
            status = new questStatus(Severity.Success, "Database successfully deleted.  Database.Id=" + databaseId.Id);
            if (bLogging)
            {
                DatabaseLog databaseLog = new DatabaseLog();
                databaseLog.Name  = "Database.Id=" + databaseId.Id;
                databaseLog.Event = "DELETE";
                databaseLog.Data  = status.ToString();
                DatabaseLogId databaseLogId = null;
                _dbDatabaseLogsMgr.Create(databaseLog, out databaseLogId);
            }
            return(status);
        }
        private questStatus read(MasterPricingEntities dbContext, string name, out Quest.Services.Dbio.MasterPricing.Databases database)
        {
            // Initialize
            questStatus status = null;

            database = null;


            try
            {
                database = dbContext.Databases.Where(r => r.Name == name).SingleOrDefault();
                if (database == null)
                {
                    return(new questStatus(Severity.Error, String.Format("ERROR: {0}.{1}: {2}",
                                                                         this.GetType().Name, MethodBase.GetCurrentMethod().Name,
                                                                         String.Format("Name {0} not found", name))));
                }
            }
            catch (System.Exception ex)
            {
                status = new questStatus(Severity.Fatal, String.Format("EXCEPTION: {0}.{1}: {2}",
                                                                       this.GetType().Name, MethodBase.GetCurrentMethod().Name,
                                                                       ex.InnerException != null ? ex.InnerException.Message : ex.Message));
                LogException(ex, status);
                return(status);
            }
            return(new questStatus(Severity.Success));
        }
        /*----------------------------------------------------------------------------------------------------------------------------------
        * Databases
        *---------------------------------------------------------------------------------------------------------------------------------*/
        private questStatus create(MasterPricingEntities dbContext, Quest.Functional.MasterPricing.Database database, out DatabaseId databaseId)
        {
            // Initialize
            questStatus status = null;

            databaseId = null;


            // Perform create
            try
            {
                Quest.Services.Dbio.MasterPricing.Databases _database = new Quest.Services.Dbio.MasterPricing.Databases();
                BufferMgr.TransferBuffer(database, _database);
                dbContext.Databases.Add(_database);
                dbContext.SaveChanges();
                if (_database.Id == 0)
                {
                    return(new questStatus(Severity.Error, "Quest.Functional.MasterPricing.Database not created"));
                }
                databaseId = new DatabaseId(_database.Id);
            }
            catch (DbEntityValidationException ex)
            {
                var    errorMessages    = ex.EntityValidationErrors.SelectMany(x => x.ValidationErrors).Select(x => x.ErrorMessage);
                String fullErrorMessage = string.Join("; ", errorMessages);
                String exceptionMessage = string.Concat(ex.Message, fullErrorMessage);

                status = new questStatus(Severity.Fatal, String.Format("EXCEPTION: {0}.{1}: {2}",
                                                                       this.GetType().Name, MethodBase.GetCurrentMethod().Name,
                                                                       exceptionMessage));
                LogException(ex, status);
                return(status);
            }
            catch (System.Exception ex)
            {
                status = new questStatus(Severity.Fatal, String.Format("EXCEPTION: {0}.{1}: {2}",
                                                                       this.GetType().Name, MethodBase.GetCurrentMethod().Name,
                                                                       ex.InnerException != null ? ex.InnerException.Message : ex.Message));
                LogException(ex, status);
                return(status);
            }
            return(new questStatus(Severity.Success));
        }
        public questStatus Read(DbMgrTransaction trans, Quest.Functional.MasterPricing.DatabaseId databaseId, out Quest.Functional.MasterPricing.Database database)
        {
            // Initialize
            questStatus status = null;

            database = null;


            // Perform read.
            using (MasterPricingEntities dbContext = new MasterPricingEntities())
            {
                Quest.Services.Dbio.MasterPricing.Databases _database = null;
                status = read((MasterPricingEntities)trans.DbContext, databaseId, out _database);
                if (!questStatusDef.IsSuccess(status))
                {
                    return(status);
                }
                database = new Quest.Functional.MasterPricing.Database();
                BufferMgr.TransferBuffer(_database, database);
            }
            return(new questStatus(Severity.Success));
        }