private questStatus create(MasterPricingEntities dbContext, List <Quest.Functional.MasterPricing.StoredProcedure> storedProcedureList, out List <Quest.Functional.MasterPricing.StoredProcedure> storedProcedureIdList)
        {
            // Initialize
            questStatus status = null;

            storedProcedureIdList = null;


            // Perform create
            try
            {
                List <Quest.Services.Dbio.MasterPricing.StoredProcedures> _storedProcedureList = new List <Quest.Services.Dbio.MasterPricing.StoredProcedures>();
                foreach (Quest.Functional.MasterPricing.StoredProcedure storedProcedure in storedProcedureList)
                {
                    Quest.Services.Dbio.MasterPricing.StoredProcedures _storedProcedure = new Quest.Services.Dbio.MasterPricing.StoredProcedures();
                    BufferMgr.TransferBuffer(storedProcedure, _storedProcedure);
                    _storedProcedureList.Add(_storedProcedure);
                }
                dbContext.StoredProcedures.AddRange(_storedProcedureList);
                dbContext.SaveChanges();

                storedProcedureIdList = new List <StoredProcedure>();
                foreach (Quest.Services.Dbio.MasterPricing.StoredProcedures _storedProcedure in _storedProcedureList)
                {
                    Quest.Functional.MasterPricing.StoredProcedure storedProcedure = new StoredProcedure();
                    storedProcedure.Id = _storedProcedure.Id;
                    storedProcedureIdList.Add(storedProcedure);
                }
            }
            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));
        }
        private questStatus update(MasterPricingEntities dbContext, Quest.Functional.MasterPricing.StoredProcedure storedProcedure)
        {
            // Initialize
            questStatus status = null;


            try
            {
                // Read the record.
                StoredProcedureId storedProcedureId = new StoredProcedureId(storedProcedure.Id);
                Quest.Services.Dbio.MasterPricing.StoredProcedures _storedProcedures = null;
                status = read(dbContext, storedProcedureId, out _storedProcedures);
                if (!questStatusDef.IsSuccess(status))
                {
                    return(status);
                }

                // Update the record.
                BufferMgr.TransferBuffer(storedProcedure, _storedProcedures);
                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);
            }
            return(new questStatus(Severity.Success));
        }
        public questStatus Read(DbMgrTransaction trans, StoredProcedureId storedProcedureId, out Quest.Functional.MasterPricing.StoredProcedure storedProcedure)
        {
            // Initialize
            questStatus status = null;

            storedProcedure = null;


            // Perform read
            Quest.Services.Dbio.MasterPricing.StoredProcedures _storedProcedures = null;
            status = read((MasterPricingEntities)trans.DbContext, storedProcedureId, out _storedProcedures);
            if (!questStatusDef.IsSuccess(status))
            {
                return(status);
            }
            storedProcedure = new Quest.Functional.MasterPricing.StoredProcedure();
            BufferMgr.TransferBuffer(_storedProcedures, storedProcedure);

            return(new questStatus(Severity.Success));
        }
        public questStatus Read(DatabaseId databaseId, string storedProcedureName, out Quest.Functional.MasterPricing.StoredProcedure storedProcedure)
        {
            // Initialize
            questStatus status = null;

            storedProcedure = null;


            // Perform read
            using (MasterPricingEntities dbContext = new MasterPricingEntities())
            {
                Quest.Services.Dbio.MasterPricing.StoredProcedures _storedProcedure = null;
                status = read(dbContext, databaseId, storedProcedureName, out _storedProcedure);
                if (!questStatusDef.IsSuccess(status))
                {
                    return(status);
                }
                storedProcedure = new StoredProcedure();
                BufferMgr.TransferBuffer(_storedProcedure, storedProcedure);
            }
            return(new questStatus(Severity.Success));
        }
        private questStatus read(MasterPricingEntities dbContext, DatabaseId databaseId, string storedProcedureName, out Quest.Services.Dbio.MasterPricing.StoredProcedures storedProcedure)
        {
            // Initialize
            questStatus status = null;

            storedProcedure = null;


            try
            {
                storedProcedure = dbContext.StoredProcedures.Where(r => r.DatabaseId == databaseId.Id && r.Name == storedProcedureName).SingleOrDefault();
                if (storedProcedure == null)
                {
                    return(new questStatus(Severity.Error, String.Format("ERROR: {0}.{1}: {2}",
                                                                         this.GetType().Name, MethodBase.GetCurrentMethod().Name,
                                                                         String.Format("DatabaseId {0} not found", databaseId.Id))));
                }
            }
            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));
        }