public static int Create(TraceDataModel data, RequestProfile requestProfile) { var sql = Save(data, "Create", requestProfile); var newId = DBDML.RunScalarSQL("Trace.Insert", sql, DataStoreKey); return(Convert.ToInt32(newId)); }
public static string Save(TraceDataModel data, string action, RequestProfile requestProfile) { var sql = "EXEC "; switch (action) { case "Create": sql += "dbo.TraceInsert " + " " + ToSQLParameter(BaseDataModel.BaseDataColumns.AuditId, requestProfile.AuditId) + ", " + ToSQLParameter(BaseDataModel.BaseDataColumns.ApplicationId, requestProfile.ApplicationId); break; case "Update": sql += "dbo.TraceUpdate " + " " + ToSQLParameter(BaseDataModel.BaseDataColumns.AuditId, requestProfile.AuditId); break; default: break; } sql = sql + ", " + ToSQLParameter(data, TraceDataModel.DataColumns.TraceId) + ", " + ToSQLParameter(data, StandardDataModel.StandardDataColumns.Name) + ", " + ToSQLParameter(data, StandardDataModel.StandardDataColumns.Description) + ", " + ToSQLParameter(data, StandardDataModel.StandardDataColumns.SortOrder); return(sql); }
public static DataSet GetChildren(TraceDataModel data, RequestProfile requestProfile) { var sql = "EXEC dbo.TraceChildrenGet" + " " + ToSQLParameter(BaseDataModel.BaseDataColumns.AuditId, requestProfile.AuditId) + ", " + ToSQLParameter(data, TraceDataModel.DataColumns.TraceId); var oDT = new Framework.Components.DataAccess.DBDataSet("Get Children", sql, DataStoreKey); return(oDT.DBDataset); }
public static bool DoesExist(TraceDataModel data, RequestProfile requestProfile) { var doesExistRequest = new TraceDataModel(); doesExistRequest.ApplicationId = data.ApplicationId; doesExistRequest.Name = data.Name; var list = GetEntityDetails(doesExistRequest, requestProfile, 0); return(list.Count > 0); }
public static void Delete(TraceDataModel data, RequestProfile requestProfile) { const string sql = @"dbo.TraceDelete "; var parameters = new { AuditId = requestProfile.AuditId , TraceId = data.TraceId }; using (var dataAccess = new DataAccessBase(DataStoreKey)) { dataAccess.Connection.Execute(sql, parameters, commandType: CommandType.StoredProcedure); } }
public static bool IsDeletable(TraceDataModel data, RequestProfile requestProfile) { var isDeletable = true; var ds = GetChildren(data, requestProfile); if (ds != null && ds.Tables.Count > 0) { foreach (DataTable dt in ds.Tables) { if (dt.Rows.Count > 0) { isDeletable = false; break; } } } return(isDeletable); }
public static List <TraceDataModel> GetEntityDetails(TraceDataModel dataQuery, RequestProfile requestProfile, int returnAuditInfo = BaseDataManager.ReturnAuditInfoOnDetails) { const string sql = @"dbo.TraceSearch "; var parameters = new { AuditId = requestProfile.AuditId , ApplicationId = requestProfile.ApplicationId , ApplicationMode = requestProfile.ApplicationModeId , ReturnAuditInfo = returnAuditInfo , TraceId = dataQuery.TraceId , Name = dataQuery.Name }; List <TraceDataModel> result; using (var dataAccess = new DataAccessBase(DataStoreKey)) { result = dataAccess.Connection.Query <TraceDataModel>(sql, parameters, commandType: CommandType.StoredProcedure).ToList(); } return(result); }
public static string ToSQLParameter(TraceDataModel data, string dataColumnName) { var returnValue = "NULL"; switch (dataColumnName) { case TraceDataModel.DataColumns.TraceId: if (data.TraceId != null) { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NUMBER, TraceDataModel.DataColumns.TraceId, data.TraceId); } else { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, TraceDataModel.DataColumns.TraceId); } break; default: returnValue = StandardDataManager.ToSQLParameter(data, dataColumnName); break; } return(returnValue); }
public static DataTable Search(TraceDataModel data, RequestProfile requestProfile) { var list = GetEntityDetails(data, requestProfile, 0); return(list.ToDataTable()); }
public static void Update(TraceDataModel data, RequestProfile requestProfile) { var sql = Save(data, "Update", requestProfile); DBDML.RunSQL("Trace.Update", sql, DataStoreKey); }
public static TraceDataModel GetDetails(TraceDataModel data, RequestProfile requestProfile) { var list = GetEntityDetails(data, requestProfile, 1); return(list.FirstOrDefault()); }