Beispiel #1
0
        public questStatus List(QueryOptions queryOptions, out List <Quest.Functional.MasterPricing.View> viewList, out QueryResponse queryResponse)
        {
            // Initialize
            questStatus status = null;

            viewList      = null;
            queryResponse = null;


            using (MasterPricingEntities dbContext = new MasterPricingEntities())
            {
                using (DbContextTransaction tx = dbContext.Database.BeginTransaction(IsolationLevel.ReadUncommitted))
                {
                    try
                    {
                        PropertyInfo[] dbProperties = typeof(Quest.Services.Dbio.MasterPricing.Views).GetProperties().ToArray();
                        int            totalRecords = dbContext.Views.Where(BuildWhereClause(queryOptions, dbProperties)).Count();
                        List <Quest.Services.Dbio.MasterPricing.Views> _countriesList = dbContext.Views.Where(BuildWhereClause(queryOptions, dbProperties))
                                                                                        .OrderBy(BuildSortString(queryOptions.SortColumns))
                                                                                        .Skip(queryOptions.Paging.PageSize * (queryOptions.Paging.PageNumber - 1))
                                                                                        .Take(queryOptions.Paging.PageSize).ToList();
                        if (_countriesList == null)
                        {
                            return(new questStatus(Severity.Warning));
                        }
                        viewList = new List <Quest.Functional.MasterPricing.View>();
                        foreach (Quest.Services.Dbio.MasterPricing.Views _view in _countriesList)
                        {
                            Quest.Functional.MasterPricing.View view = new Quest.Functional.MasterPricing.View();
                            BufferMgr.TransferBuffer(_view, view);
                            viewList.Add(view);
                        }
                        status = BuildQueryResponse(totalRecords, queryOptions, out queryResponse);
                        if (!questStatusDef.IsSuccess(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));
        }
Beispiel #2
0
        public questStatus Update(DbMgrTransaction trans, Quest.Functional.MasterPricing.View view)
        {
            // Initialize
            questStatus status             = null;
            bool        bCreateTransaction = trans == null;


            // Perform update in this transaction.
            status = update((MasterPricingEntities)trans.DbContext, view);
            if (!questStatusDef.IsSuccess(status))
            {
                RollbackTransaction(trans);
                return(status);
            }
            return(new questStatus(Severity.Success));
        }
Beispiel #3
0
        public questStatus Update(Quest.Functional.MasterPricing.View view)
        {
            // Initialize
            questStatus status = null;


            // Perform update.
            using (MasterPricingEntities dbContext = new MasterPricingEntities())
            {
                status = update(dbContext, view);
                if (!questStatusDef.IsSuccess(status))
                {
                    return(status);
                }
            }
            return(new questStatus(Severity.Success));
        }
Beispiel #4
0
        public questStatus Create(DbMgrTransaction trans, Quest.Functional.MasterPricing.View view, out ViewId viewId)
        {
            // Initialize
            questStatus status = null;

            viewId = null;


            // Data rules.


            // Create the view in this transaction.
            status = create((MasterPricingEntities)trans.DbContext, view, out viewId);
            if (!questStatusDef.IsSuccess(status))
            {
                return(status);
            }
            return(new questStatus(Severity.Success));
        }
Beispiel #5
0
        /*----------------------------------------------------------------------------------------------------------------------------------
        * Views
        *---------------------------------------------------------------------------------------------------------------------------------*/
        private questStatus create(MasterPricingEntities dbContext, Quest.Functional.MasterPricing.View view, out ViewId viewId)
        {
            // Initialize
            questStatus status = null;

            viewId = null;


            // Perform create
            try
            {
                Quest.Services.Dbio.MasterPricing.Views _view = new Quest.Services.Dbio.MasterPricing.Views();
                BufferMgr.TransferBuffer(view, _view);
                dbContext.Views.Add(_view);
                dbContext.SaveChanges();
                if (_view.Id == 0)
                {
                    return(new questStatus(Severity.Error, "Quest.Functional.MasterPricing.View not created"));
                }
                viewId = new ViewId(_view.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));
        }
Beispiel #6
0
        private questStatus update(MasterPricingEntities dbContext, Quest.Functional.MasterPricing.View view)
        {
            // Initialize
            questStatus status = null;


            try
            {
                // Read the record.
                ViewId viewId = new ViewId(view.Id);
                Quest.Services.Dbio.MasterPricing.Views _view = null;
                status = read(dbContext, viewId, out _view);
                if (!questStatusDef.IsSuccess(status))
                {
                    return(status);
                }

                // Update the record.
                BufferMgr.TransferBuffer(view, _view);
                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));
        }
Beispiel #7
0
        public questStatus Read(DbMgrTransaction trans, ViewId viewId, out Quest.Functional.MasterPricing.View view)
        {
            // Initialize
            questStatus status = null;

            view = null;


            // Perform read.
            Quest.Services.Dbio.MasterPricing.Views _view = null;
            status = read((MasterPricingEntities)trans.DbContext, viewId, out _view);
            if (!questStatusDef.IsSuccess(status))
            {
                return(status);
            }
            view = new Quest.Functional.MasterPricing.View();
            BufferMgr.TransferBuffer(_view, view);


            return(new questStatus(Severity.Success));
        }
Beispiel #8
0
        /*==================================================================================================================================
        * Properties
        *=================================================================================================================================*/
        #endregion


        #region Public Methods

        /*==================================================================================================================================
        * Public Methods
        *=================================================================================================================================*/
        public questStatus Create(Quest.Functional.MasterPricing.View view, out ViewId viewId)
        {
            // Initialize
            questStatus status = null;

            viewId = null;


            // Data rules.


            // Create the view
            using (MasterPricingEntities dbContext = new MasterPricingEntities())
            {
                status = create(dbContext, view, out viewId);
                if (!questStatusDef.IsSuccess(status))
                {
                    return(status);
                }
            }
            return(new questStatus(Severity.Success));
        }
Beispiel #9
0
        public questStatus Read(DatabaseId databaseId, string schema, string name, out Quest.Functional.MasterPricing.View view)
        {
            // Initialize
            questStatus status = null;

            view = null;


            // Perform read
            using (MasterPricingEntities dbContext = new MasterPricingEntities())
            {
                Quest.Services.Dbio.MasterPricing.Views _view = null;
                status = read(dbContext, databaseId, schema, name, out _view);
                if (!questStatusDef.IsSuccess(status))
                {
                    return(status);
                }
                view = new Quest.Functional.MasterPricing.View();
                BufferMgr.TransferBuffer(_view, view);
            }
            return(new questStatus(Severity.Success));
        }