示例#1
0
        public void Delete(string value)
        {
            var dataDelete = new PriceMarketDataModel();

            dataDelete.PriceMarketId = int.Parse(value);
            PriceMarketDataManager.Delete(dataDelete, SessionVariables.RequestProfile);
        }
示例#2
0
        public static int Create(PriceMarketDataModel data, RequestProfile requestProfile)
        {
            var sql   = Save(data, "Create", requestProfile);
            var newId = DBDML.RunScalarSQL("PriceMarket.Insert", sql, DataStoreKey);

            return(Convert.ToInt32(newId));
        }
示例#3
0
        public static string Save(PriceMarketDataModel data, string action, RequestProfile requestProfile)
        {
            var sql = "EXEC ";


            switch (action)
            {
            case "Create":
                sql += "dbo.PriceMarketInsert  " +
                       " " + ToSQLParameter(BaseDataModel.BaseDataColumns.AuditId, requestProfile.AuditId) +
                       ", " + ToSQLParameter(BaseDataModel.BaseDataColumns.ApplicationId, requestProfile.ApplicationId);
                break;

            case "Update":
                sql += "dbo.PriceMarketUpdate  " +
                       " " + ToSQLParameter(BaseDataModel.BaseDataColumns.AuditId, requestProfile.AuditId);
                break;

            default:
                break;
            }
            sql = sql + ", " + ToSQLParameter(data, PriceMarketDataModel.DataColumns.PriceMarketId);
            sql = sql + ", " + ToSQLParameter(data, PriceMarketDataModel.DataColumns.Name);
            sql = sql + ", " + ToSQLParameter(data, PriceMarketDataModel.DataColumns.Description);
            sql = sql + ", " + ToSQLParameter(data, PriceMarketDataModel.DataColumns.SortOrder);

            return(sql);
        }
示例#4
0
        public static string ToSQLParameter(PriceMarketDataModel data, string dataColumnName)
        {
            var returnValue = "NULL";

            switch (dataColumnName)
            {
            case PriceMarketDataModel.DataColumns.PriceMarketId:
                if (data.PriceMarketId != null)
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NUMBER, PriceMarketDataModel.DataColumns.PriceMarketId, data.PriceMarketId);
                }
                else
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, PriceMarketDataModel.DataColumns.PriceMarketId);
                }
                break;

            case PriceMarketDataModel.DataColumns.Name:
                if (!string.IsNullOrEmpty(data.Name))
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_STRING_OR_DATE, PriceMarketDataModel.DataColumns.Name, data.Name);
                }
                else
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, PriceMarketDataModel.DataColumns.Name);
                }
                break;

            case PriceMarketDataModel.DataColumns.Description:
                if (!string.IsNullOrEmpty(data.Description))
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_STRING_OR_DATE, PriceMarketDataModel.DataColumns.Description, data.Description);
                }
                else
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, PriceMarketDataModel.DataColumns.Description);
                }
                break;

            case PriceMarketDataModel.DataColumns.SortOrder:
                if (data.SortOrder != null)
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NUMBER, PriceMarketDataModel.DataColumns.SortOrder, data.SortOrder);
                }
                else
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, PriceMarketDataModel.DataColumns.SortOrder);
                }
                break;


            default:
                returnValue = BaseDataManager.ToSQLParameter(data, dataColumnName);
                break;
            }

            return(returnValue);
        }
示例#5
0
        public PriceMarketDataModel GetById(string value)
        {
            var dataQuery = new PriceMarketDataModel();

            dataQuery.PriceMarketId = int.Parse(value);

            var result = PriceMarketDataManager.GetEntityDetails(dataQuery, SessionVariables.RequestProfile, 1);

            return(result[0]);
        }
示例#6
0
        public static bool DoesExist(PriceMarketDataModel data, RequestProfile requestProfile)
        {
            var doesExistRequest = new PriceMarketDataModel();

            doesExistRequest.ApplicationId = data.ApplicationId;
            doesExistRequest.Name          = data.Name;

            var list = GetEntityDetails(doesExistRequest, requestProfile, 0);

            return(list.Count > 0);
        }
示例#7
0
        public static void Delete(PriceMarketDataModel data, RequestProfile requestProfile)
        {
            const string sql = @"dbo.PriceMarketDelete ";

            var parameters =
                new
            {
                AuditId         = requestProfile.AuditId
                , PriceMarketId = data.PriceMarketId
            };

            using (var dataAccess = new DataAccessBase(DataStoreKey))
            {
                dataAccess.Connection.Execute(sql, parameters, commandType: CommandType.StoredProcedure);
            }
        }
示例#8
0
        public static List <PriceMarketDataModel> GetEntityDetails(PriceMarketDataModel dataQuery, RequestProfile requestProfile, int returnAuditInfo = BaseDataManager.ReturnAuditInfoOnDetails)
        {
            const string sql = @"dbo.PriceMarketSearch ";

            var parameters =
                new
            {
                AuditId           = requestProfile.AuditId
                , ApplicationId   = requestProfile.ApplicationId
                , ReturnAuditInfo = returnAuditInfo
                , PriceMarketId   = dataQuery.PriceMarketId
                , Name            = dataQuery.Name
            };

            List <PriceMarketDataModel> result;

            using (var dataAccess = new DataAccessBase(DataStoreKey))
            {
                result = dataAccess.Connection.Query <PriceMarketDataModel>(sql, parameters, commandType: CommandType.StoredProcedure).ToList();
            }

            return(result);
        }
示例#9
0
        public static void Update(PriceMarketDataModel data, RequestProfile requestProfile)
        {
            var sql = Save(data, "Update", requestProfile);

            DBDML.RunSQL("PriceMarket.Update", sql, DataStoreKey);
        }
示例#10
0
        public static DataTable Search(PriceMarketDataModel data, RequestProfile requestProfile)
        {
            var list = GetEntityDetails(data, requestProfile, 0);

            return(list.ToDataTable());
        }