예제 #1
0
        public static int Create(AnalystDataModel data, RequestProfile requestProfile)
        {
            var sql   = Save(data, "Create", requestProfile);
            var newId = DBDML.RunScalarSQL("Analyst.Insert", sql, DataStoreKey);

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


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

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

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

            return(sql);
        }
예제 #3
0
        public void Delete(string value)
        {
            var dataDelete = new AnalystDataModel();

            dataDelete.AnalystId = int.Parse(value);
            AnalystDataManager.Delete(dataDelete, SessionVariables.RequestProfile);
        }
예제 #4
0
        public static string ToSQLParameter(AnalystDataModel data, string dataColumnName)
        {
            var returnValue = "NULL";

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

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

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

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


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

            return(returnValue);
        }
예제 #5
0
        public AnalystDataModel GetById(string value)
        {
            var dataQuery = new AnalystDataModel();

            dataQuery.AnalystId = int.Parse(value);

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

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

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

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

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

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

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

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

            List <AnalystDataModel> result;

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

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

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

            return(list.ToDataTable());
        }