public questStatus Read(LookupId lookupId, out LookupEditorViewModel lookupEditorViewModel)
        {
            // Initialize
            questStatus status = null;

            lookupEditorViewModel = null;


            // Read
            Quest.Functional.MasterPricing.Lookup lookup = null;
            LookupsMgr lookupsMgr = new LookupsMgr(this.UserSession);

            status = lookupsMgr.Read(lookupId, out lookup);
            if (!questStatusDef.IsSuccess(status))
            {
                return(status);
            }

            // Transfer model.
            lookupEditorViewModel = new LookupEditorViewModel(this.UserSession);
            BufferMgr.TransferBuffer(lookup, lookupEditorViewModel);



            return(new questStatus(Severity.Success));
        }
Ejemplo n.º 2
0
        public questStatus List(QueryOptions queryOptions, out List <Quest.Functional.MasterPricing.Lookup> lookupList, out QueryResponse queryResponse)
        {
            // Initialize
            questStatus status = null;

            lookupList    = null;
            queryResponse = null;


            using (MasterPricingEntities dbContext = new MasterPricingEntities())
            {
                using (DbContextTransaction tx = dbContext.Database.BeginTransaction(IsolationLevel.ReadUncommitted))
                {
                    try
                    {
                        PropertyInfo[] dbProperties = typeof(Quest.Services.Dbio.MasterPricing.Lookups).GetProperties().ToArray();
                        int            totalRecords = dbContext.vwLookupsList4.Where(BuildWhereClause(queryOptions, dbProperties)).Count();
                        List <Quest.Services.Dbio.MasterPricing.vwLookupsList4> _lookupsList = dbContext.vwLookupsList4.Where(BuildWhereClause(queryOptions, dbProperties))
                                                                                               .OrderBy(BuildSortString(queryOptions.SortColumns))
                                                                                               .Skip(queryOptions.Paging.PageSize * (queryOptions.Paging.PageNumber - 1))
                                                                                               .Take(queryOptions.Paging.PageSize).ToList();
                        if (_lookupsList == null)
                        {
                            return(new questStatus(Severity.Warning));
                        }
                        lookupList = new List <Quest.Functional.MasterPricing.Lookup>();
                        foreach (Quest.Services.Dbio.MasterPricing.vwLookupsList4 _lookup in _lookupsList)
                        {
                            Quest.Functional.MasterPricing.Lookup lookup = new Quest.Functional.MasterPricing.Lookup();
                            BufferMgr.TransferBuffer(_lookup, lookup);
                            lookupList.Add(lookup);
                        }
                        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));
        }
Ejemplo n.º 3
0
        public questStatus Update(DbMgrTransaction trans, Quest.Functional.MasterPricing.Lookup lookup)
        {
            // Initialize
            questStatus status             = null;
            bool        bCreateTransaction = trans == null;


            // Perform update in this transaction.
            status = update((MasterPricingEntities)trans.DbContext, lookup);
            if (!questStatusDef.IsSuccess(status))
            {
                RollbackTransaction(trans);
                return(status);
            }
            return(new questStatus(Severity.Success));
        }
Ejemplo n.º 4
0
        public questStatus Update(Quest.Functional.MasterPricing.Lookup lookup)
        {
            // Initialize
            questStatus status = null;


            // Perform update.
            using (MasterPricingEntities dbContext = new MasterPricingEntities())
            {
                status = update(dbContext, lookup);
                if (!questStatusDef.IsSuccess(status))
                {
                    return(status);
                }
            }
            return(new questStatus(Severity.Success));
        }
Ejemplo n.º 5
0
        public questStatus Create(DbMgrTransaction trans, Quest.Functional.MasterPricing.Lookup lookup, out LookupId lookupId)
        {
            // Initialize
            questStatus status = null;

            lookupId = null;


            // Data rules.


            // Create the lookup in this transaction.
            status = create((MasterPricingEntities)trans.DbContext, lookup, out lookupId);
            if (!questStatusDef.IsSuccess(status))
            {
                return(status);
            }
            return(new questStatus(Severity.Success));
        }
Ejemplo n.º 6
0
        /*----------------------------------------------------------------------------------------------------------------------------------
        * Lookups
        *---------------------------------------------------------------------------------------------------------------------------------*/
        private questStatus create(MasterPricingEntities dbContext, Quest.Functional.MasterPricing.Lookup lookup, out LookupId lookupId)
        {
            // Initialize
            questStatus status = null;

            lookupId = null;


            // Perform create
            try
            {
                Quest.Services.Dbio.MasterPricing.Lookups _lookup = new Quest.Services.Dbio.MasterPricing.Lookups();
                BufferMgr.TransferBuffer(lookup, _lookup);
                dbContext.Lookups.Add(_lookup);
                dbContext.SaveChanges();
                if (_lookup.Id == 0)
                {
                    return(new questStatus(Severity.Error, "Quest.Functional.MasterPricing.Lookup not created"));
                }
                lookupId = new LookupId(_lookup.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));
        }
Ejemplo n.º 7
0
        /*==================================================================================================================================
        * Properties
        *=================================================================================================================================*/
        #endregion


        #region Public Methods

        /*==================================================================================================================================
        * Public Methods
        *=================================================================================================================================*/
        public questStatus Create(Quest.Functional.MasterPricing.Lookup lookup, out LookupId lookupId)
        {
            // Initialize
            questStatus status = null;

            lookupId = null;


            // Data rules.


            // Create the lookup
            using (MasterPricingEntities dbContext = new MasterPricingEntities())
            {
                status = create(dbContext, lookup, out lookupId);
                if (!questStatusDef.IsSuccess(status))
                {
                    return(status);
                }
            }
            return(new questStatus(Severity.Success));
        }
Ejemplo n.º 8
0
        public questStatus Read(DbMgrTransaction trans, LookupId lookupId, out Quest.Functional.MasterPricing.Lookup lookup)
        {
            // Initialize
            questStatus status = null;

            lookup = null;


            // Perform read.
            using (MasterPricingEntities dbContext = new MasterPricingEntities())
            {
                Quest.Services.Dbio.MasterPricing.Lookups _lookup = null;
                status = read((MasterPricingEntities)trans.DbContext, lookupId, out _lookup);
                if (!questStatusDef.IsSuccess(status))
                {
                    return(status);
                }
                lookup = new Quest.Functional.MasterPricing.Lookup();
                BufferMgr.TransferBuffer(_lookup, lookup);
            }
            return(new questStatus(Severity.Success));
        }