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)); }
public void Delete(string value) { var dataQuery = new AccidentReportDataModel(); dataQuery.AccidentReportId = int.Parse(value); AccidentReportDataManager.Delete(dataQuery, SessionVariables.RequestProfile); }
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); }
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); }
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]); }
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); }
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); } }
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); }
public void Update([FromBody] AccidentReportDataModel data) { AccidentReportDataManager.Update(data, SessionVariables.RequestProfile); }
public static void Update(AccidentReportDataModel data, RequestProfile requestProfile) { var sql = Save(data, "Update", requestProfile); DBDML.RunSQL("AccidentReport.Update", sql, DataStoreKey); }
public static DataTable Search(AccidentReportDataModel data, RequestProfile requestProfile) { var list = GetEntityDetails(data, requestProfile, 0); return(list.ToDataTable()); }