Пример #1
0
        public static int Create(CreditDefaultSwapIndexDataModel data, RequestProfile requestProfile)
        {
            var sql   = Save(data, "Create", requestProfile);
            var newId = DBDML.RunScalarSQL("CreditDefaultSwapIndex.Insert", sql, DataStoreKey);

            return(Convert.ToInt32(newId));
        }
Пример #2
0
        public static string Save(CreditDefaultSwapIndexDataModel data, string action, RequestProfile requestProfile)
        {
            var sql = "EXEC ";


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

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

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

            return(sql);
        }
Пример #3
0
        public void Delete(string value)
        {
            var dataDelete = new CreditDefaultSwapIndexDataModel();

            dataDelete.CreditDefaultSwapIndexId = int.Parse(value);
            CreditDefaultSwapIndexDataManager.Delete(dataDelete, SessionVariables.RequestProfile);
        }
Пример #4
0
        public static string ToSQLParameter(CreditDefaultSwapIndexDataModel data, string dataColumnName)
        {
            var returnValue = "NULL";

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

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

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

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


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

            return(returnValue);
        }
Пример #5
0
        public CreditDefaultSwapIndexDataModel GetById(string value)
        {
            var dataQuery = new CreditDefaultSwapIndexDataModel();

            dataQuery.CreditDefaultSwapIndexId = int.Parse(value);

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

            return(result[0]);
        }
Пример #6
0
        public static bool DoesExist(CreditDefaultSwapIndexDataModel data, RequestProfile requestProfile)
        {
            var doesExistRequest = new CreditDefaultSwapIndexDataModel();

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

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

            return(list.Count > 0);
        }
Пример #7
0
        public static void Delete(CreditDefaultSwapIndexDataModel data, RequestProfile requestProfile)
        {
            const string sql = @"dbo.CreditDefaultSwapIndexDelete ";

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

            using (var dataAccess = new DataAccessBase(DataStoreKey))
            {
                dataAccess.Connection.Execute(sql, parameters, commandType: CommandType.StoredProcedure);
            }
        }
Пример #8
0
        public static List <CreditDefaultSwapIndexDataModel> GetEntityDetails(CreditDefaultSwapIndexDataModel dataQuery, RequestProfile requestProfile, int returnAuditInfo = BaseDataManager.ReturnAuditInfoOnDetails)
        {
            const string sql = @"dbo.CreditDefaultSwapIndexSearch ";

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

            List <CreditDefaultSwapIndexDataModel> result;

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

            return(result);
        }
Пример #9
0
        public static void Update(CreditDefaultSwapIndexDataModel data, RequestProfile requestProfile)
        {
            var sql = Save(data, "Update", requestProfile);

            DBDML.RunSQL("CreditDefaultSwapIndex.Update", sql, DataStoreKey);
        }
Пример #10
0
        public static DataTable Search(CreditDefaultSwapIndexDataModel data, RequestProfile requestProfile)
        {
            var list = GetEntityDetails(data, requestProfile, 0);

            return(list.ToDataTable());
        }