Esempio n. 1
0
        public void Delete(string value)
        {
            var dataDelete = new EquityDataModel();

            dataDelete.EquityId = int.Parse(value);
            EquityDataManager.Delete(dataDelete, SessionVariables.RequestProfile);
        }
Esempio n. 2
0
        public static int Create(EquityDataModel data, RequestProfile requestProfile)
        {
            var sql   = Save(data, "Create", requestProfile);
            var newId = DBDML.RunScalarSQL("Equity.Insert", sql, DataStoreKey);

            return(Convert.ToInt32(newId));
        }
Esempio n. 3
0
        public static string Save(EquityDataModel data, string action, RequestProfile requestProfile)
        {
            var sql = "EXEC ";


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

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

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

            return(sql);
        }
Esempio n. 4
0
        public static string ToSQLParameter(EquityDataModel data, string dataColumnName)
        {
            var returnValue = "NULL";

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

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

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

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


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

            return(returnValue);
        }
Esempio n. 5
0
        public EquityDataModel GetById(string value)
        {
            var dataQuery = new EquityDataModel();

            dataQuery.EquityId = int.Parse(value);

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

            return(result[0]);
        }
Esempio n. 6
0
        public static bool DoesExist(EquityDataModel data, RequestProfile requestProfile)
        {
            var doesExistRequest = new EquityDataModel();

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

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

            return(list.Count > 0);
        }
Esempio n. 7
0
        public static void Delete(EquityDataModel data, RequestProfile requestProfile)
        {
            const string sql = @"dbo.EquityDelete ";

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

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

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

            List <EquityDataModel> result;

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

            return(result);
        }
Esempio n. 9
0
        public static void Update(EquityDataModel data, RequestProfile requestProfile)
        {
            var sql = Save(data, "Update", requestProfile);

            DBDML.RunSQL("Equity.Update", sql, DataStoreKey);
        }
Esempio n. 10
0
        public static DataTable Search(EquityDataModel data, RequestProfile requestProfile)
        {
            var list = GetEntityDetails(data, requestProfile, 0);

            return(list.ToDataTable());
        }