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

            return(Convert.ToInt32(newId));
        }
예제 #2
0
        public void Delete(string value)
        {
            var dataQuery = new AccidentReportDataModel();

            dataQuery.AccidentReportId = int.Parse(value);
            AccidentReportDataManager.Delete(dataQuery, SessionVariables.RequestProfile);
        }
예제 #3
0
        public static string Save(AccidentReportDataModel data, string action, RequestProfile requestProfile)
        {
            var sql = "EXEC ";


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

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

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

            return(sql);
        }
예제 #4
0
        public static string ToSQLParameter(AccidentReportDataModel data, string dataColumnName)
        {
            var returnValue = "NULL";

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

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

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

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


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

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

            dataQuery.AccidentReportId = int.Parse(value);
            var result = AccidentReportDataManager.GetEntityDetails(dataQuery, SessionVariables.RequestProfile, 1);

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

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

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

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

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

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

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

            List <AccidentReportDataModel> result;

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

            return(result);
        }
예제 #9
0
 public void Update([FromBody] AccidentReportDataModel data)
 {
     AccidentReportDataManager.Update(data, SessionVariables.RequestProfile);
 }
예제 #10
0
        public static void Update(AccidentReportDataModel data, RequestProfile requestProfile)
        {
            var sql = Save(data, "Update", requestProfile);

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

            return(list.ToDataTable());
        }