public questStatus Read(TypeListId typeListId, out TypeListEditorViewModel typeListEditorViewModel)
        {
            // Initialize
            questStatus status = null;

            typeListEditorViewModel = null;


            // Read
            Quest.Functional.MasterPricing.TypeList typeList = null;
            TypeListsMgr typeListsMgr = new TypeListsMgr(this.UserSession);

            status = typeListsMgr.Read(typeListId, out typeList);
            if (!questStatusDef.IsSuccess(status))
            {
                return(status);
            }

            // Transfer model.
            typeListEditorViewModel = new TypeListEditorViewModel(this.UserSession);
            BufferMgr.TransferBuffer(typeList, typeListEditorViewModel);



            return(new questStatus(Severity.Success));
        }
Example #2
0
        public questStatus List(QueryOptions queryOptions, out List <Quest.Functional.MasterPricing.TypeList> typeListList, out QueryResponse queryResponse)
        {
            // Initialize
            questStatus status = null;

            typeListList  = null;
            queryResponse = null;


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


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


            // Perform update.
            using (MasterPricingEntities dbContext = new MasterPricingEntities())
            {
                status = update(dbContext, typeList);
                if (!questStatusDef.IsSuccess(status))
                {
                    return(status);
                }
            }
            return(new questStatus(Severity.Success));
        }
Example #5
0
        public questStatus Create(DbMgrTransaction trans, Quest.Functional.MasterPricing.TypeList typeList, out TypeListId typeListId)
        {
            // Initialize
            questStatus status = null;

            typeListId = null;


            // Data rules.


            // Create the typeList in this transaction.
            status = create((MasterPricingEntities)trans.DbContext, typeList, out typeListId);
            if (!questStatusDef.IsSuccess(status))
            {
                return(status);
            }
            return(new questStatus(Severity.Success));
        }
Example #6
0
        /*----------------------------------------------------------------------------------------------------------------------------------
        * TypeLists
        *---------------------------------------------------------------------------------------------------------------------------------*/
        private questStatus create(MasterPricingEntities dbContext, Quest.Functional.MasterPricing.TypeList typeList, out TypeListId typeListId)
        {
            // Initialize
            questStatus status = null;

            typeListId = null;


            // Perform create
            try
            {
                Quest.Services.Dbio.MasterPricing.TypeLists _typeList = new Quest.Services.Dbio.MasterPricing.TypeLists();
                BufferMgr.TransferBuffer(typeList, _typeList);
                dbContext.TypeLists.Add(_typeList);
                dbContext.SaveChanges();
                if (_typeList.Id == 0)
                {
                    return(new questStatus(Severity.Error, "Quest.Functional.MasterPricing.TypeList not created"));
                }
                typeListId = new TypeListId(_typeList.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));
        }
Example #7
0
        /*==================================================================================================================================
        * Properties
        *=================================================================================================================================*/
        #endregion


        #region Public Methods

        /*==================================================================================================================================
        * Public Methods
        *=================================================================================================================================*/
        public questStatus Create(Quest.Functional.MasterPricing.TypeList typeList, out TypeListId typeListId)
        {
            // Initialize
            questStatus status = null;

            typeListId = null;


            // Data rules.


            // Create the typeList
            using (MasterPricingEntities dbContext = new MasterPricingEntities())
            {
                status = create(dbContext, typeList, out typeListId);
                if (!questStatusDef.IsSuccess(status))
                {
                    return(status);
                }
            }
            return(new questStatus(Severity.Success));
        }
Example #8
0
        public questStatus Read(DbMgrTransaction trans, TypeListId typeListId, out Quest.Functional.MasterPricing.TypeList typeList)
        {
            // Initialize
            questStatus status = null;

            typeList = null;


            // Perform read.
            using (MasterPricingEntities dbContext = new MasterPricingEntities())
            {
                Quest.Services.Dbio.MasterPricing.TypeLists _typeList = null;
                status = read((MasterPricingEntities)trans.DbContext, typeListId, out _typeList);
                if (!questStatusDef.IsSuccess(status))
                {
                    return(status);
                }
                typeList = new Quest.Functional.MasterPricing.TypeList();
                BufferMgr.TransferBuffer(_typeList, typeList);
            }
            return(new questStatus(Severity.Success));
        }