예제 #1
0
        public void Delete(string value)
        {
            var dataDelete = new TraderDataModel();

            dataDelete.TraderId = int.Parse(value);
            TraderDataManager.Delete(dataDelete, SessionVariables.RequestProfile);
        }
예제 #2
0
        public static int Create(TraderDataModel data, RequestProfile requestProfile)
        {
            var sql   = Save(data, "Create", requestProfile);
            var newId = DBDML.RunScalarSQL("Trader.Insert", sql, DataStoreKey);

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


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

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

            default:
                break;
            }
            sql = sql + ", " + ToSQLParameter(data, TraderDataModel.DataColumns.TraderId);
            sql = sql + ", " + ToSQLParameter(data, TraderDataModel.DataColumns.FundId);
            sql = sql + ", " + ToSQLParameter(data, TraderDataModel.DataColumns.Name);
            sql = sql + ", " + ToSQLParameter(data, TraderDataModel.DataColumns.Description);
            sql = sql + ", " + ToSQLParameter(data, TraderDataModel.DataColumns.SortOrder);

            return(sql);
        }
예제 #4
0
        public TraderDataModel GetById(string value)
        {
            var dataQuery = new TraderDataModel();

            dataQuery.TraderId = int.Parse(value);

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

            return(result[0]);
        }
예제 #5
0
        public static bool DoesExist(TraderDataModel data, RequestProfile requestProfile)
        {
            var doesExistRequest = new TraderDataModel();

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

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

            return(list.Count > 0);
        }
예제 #6
0
        public static void Delete(TraderDataModel data, RequestProfile requestProfile)
        {
            const string sql = @"dbo.TraderDelete ";

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

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

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

            List <TraderDataModel> result;

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

            return(result);
        }
예제 #8
0
        public static string ToSQLParameter(TraderDataModel data, string dataColumnName)
        {
            var returnValue = "NULL";

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

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

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

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

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

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


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

            return(returnValue);
        }
예제 #9
0
        public static void Update(TraderDataModel data, RequestProfile requestProfile)
        {
            var sql = Save(data, "Update", requestProfile);

            DBDML.RunSQL("Trader.Update", sql, DataStoreKey);
        }
예제 #10
0
        public static DataTable Search(TraderDataModel data, RequestProfile requestProfile)
        {
            var list = GetEntityDetails(data, requestProfile, 0);

            return(list.ToDataTable());
        }