public static int Create(AuditActionDataModel data, RequestProfile requestProfile) { var sql = Save(data, "Create", requestProfile); var newId = DBDML.RunScalarSQL("AuditAction.Insert", sql, DataStoreKey); return(Convert.ToInt32(newId)); }
public static string Save(AuditActionDataModel data, string action, RequestProfile requestProfile) { var sql = "EXEC "; switch (action) { case "Create": sql += "dbo.AuditActionInsert " + " " + ToSQLParameter(BaseDataModel.BaseDataColumns.AuditId, requestProfile.AuditId) + ", " + ToSQLParameter(BaseDataModel.BaseDataColumns.ApplicationId, requestProfile.ApplicationId); break; case "Update": sql += "dbo.AuditActionUpdate " + " " + ToSQLParameter(BaseDataModel.BaseDataColumns.AuditId, requestProfile.AuditId); break; default: break; } sql = sql + ", " + ToSQLParameter(data, AuditActionDataModel.DataColumns.AuditActionId) + ", " + ToSQLParameter(data, StandardDataModel.StandardDataColumns.Name) + ", " + ToSQLParameter(data, StandardDataModel.StandardDataColumns.Description) + ", " + ToSQLParameter(data, StandardDataModel.StandardDataColumns.SortOrder); return(sql); }
public static DataSet GetChildren(AuditActionDataModel data, RequestProfile requestProfile) { var sql = "EXEC dbo.AuditActionChildrenGet" + " " + ToSQLParameter(BaseDataModel.BaseDataColumns.AuditId, requestProfile.AuditId) + ", " + ToSQLParameter(data, AuditActionDataModel.DataColumns.AuditActionId); var oDT = new Framework.Components.DataAccess.DBDataSet("Get Children", sql, DataStoreKey); return(oDT.DBDataset); }
public static bool DoesExist(AuditActionDataModel data, RequestProfile requestProfile) { var doesExistRequest = new AuditActionDataModel(); doesExistRequest.ApplicationId = data.ApplicationId; doesExistRequest.Name = data.Name; var list = GetEntityDetails(doesExistRequest, requestProfile, 0); return(list.Count > 0); }
public static void Delete(AuditActionDataModel data, RequestProfile requestProfile) { const string sql = @"dbo.AuditActionDelete "; var parameters = new { AuditId = requestProfile.AuditId , AuditActionId = data.AuditActionId }; using (var dataAccess = new DataAccessBase(DataStoreKey)) { dataAccess.Connection.Execute(sql, parameters, commandType: CommandType.StoredProcedure); } }
public static bool IsDeletable(AuditActionDataModel 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 <AuditActionDataModel> GetEntityDetails(AuditActionDataModel dataQuery, RequestProfile requestProfile, int returnAuditInfo = BaseDataManager.ReturnAuditInfoOnDetails) { const string sql = @"dbo.AuditActionSearch "; var parameters = new { AuditId = requestProfile.AuditId , ApplicationId = requestProfile.ApplicationId , ApplicationMode = requestProfile.ApplicationModeId , ReturnAuditInfo = returnAuditInfo , AuditActionId = dataQuery.AuditActionId , Name = dataQuery.Name }; List <AuditActionDataModel> result; using (var dataAccess = new DataAccessBase(DataStoreKey)) { result = dataAccess.Connection.Query <AuditActionDataModel>(sql, parameters, commandType: CommandType.StoredProcedure).ToList(); } return(result); }
public static string ToSQLParameter(AuditActionDataModel data, string dataColumnName) { var returnValue = "NULL"; switch (dataColumnName) { case AuditActionDataModel.DataColumns.AuditActionId: if (data.AuditActionId != null) { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NUMBER, AuditActionDataModel.DataColumns.AuditActionId, data.AuditActionId); } else { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, AuditActionDataModel.DataColumns.AuditActionId); } break; default: returnValue = StandardDataManager.ToSQLParameter(data, dataColumnName); break; } return(returnValue); }
public static DataTable Search(AuditActionDataModel data, RequestProfile requestProfile) { var list = GetEntityDetails(data, requestProfile, 0); return(list.ToDataTable()); }
public static void Update(AuditActionDataModel data, RequestProfile requestProfile) { var sql = Save(data, "Update", requestProfile); DBDML.RunSQL("AuditAction.Update", sql, DataStoreKey); }
public static AuditActionDataModel GetDetails(AuditActionDataModel data, RequestProfile requestProfile) { var list = GetEntityDetails(data, requestProfile, 1); return(list.FirstOrDefault()); }