public static int Create(SecurityTypeDataModel data, RequestProfile requestProfile) { var sql = Save(data, "Create", requestProfile); var newId = DBDML.RunScalarSQL("SecurityType.Insert", sql, DataStoreKey); return(Convert.ToInt32(newId)); }
public static string Save(SecurityTypeDataModel data, string action, RequestProfile requestProfile) { var sql = "EXEC "; switch (action) { case "Create": sql += "dbo.SecurityTypeInsert " + " " + ToSQLParameter(BaseDataModel.BaseDataColumns.AuditId, requestProfile.AuditId) + ", " + ToSQLParameter(BaseDataModel.BaseDataColumns.ApplicationId, requestProfile.ApplicationId); break; case "Update": sql += "dbo.SecurityTypeUpdate " + " " + ToSQLParameter(BaseDataModel.BaseDataColumns.AuditId, requestProfile.AuditId); break; default: break; } sql = sql + ", " + ToSQLParameter(data, SecurityTypeDataModel.DataColumns.SecurityTypeId); sql = sql + ", " + ToSQLParameter(data, SecurityTypeDataModel.DataColumns.Name); sql = sql + ", " + ToSQLParameter(data, SecurityTypeDataModel.DataColumns.Description); sql = sql + ", " + ToSQLParameter(data, SecurityTypeDataModel.DataColumns.SortOrder); return(sql); }
public void Delete(string value) { var dataDelete = new SecurityTypeDataModel(); dataDelete.SecurityTypeId = int.Parse(value); SecurityTypeDataManager.Delete(dataDelete, SessionVariables.RequestProfile); }
public static string ToSQLParameter(SecurityTypeDataModel data, string dataColumnName) { var returnValue = "NULL"; switch (dataColumnName) { case SecurityTypeDataModel.DataColumns.SecurityTypeId: if (data.SecurityTypeId != null) { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NUMBER, SecurityTypeDataModel.DataColumns.SecurityTypeId, data.SecurityTypeId); } else { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, SecurityTypeDataModel.DataColumns.SecurityTypeId); } break; case SecurityTypeDataModel.DataColumns.Name: if (!string.IsNullOrEmpty(data.Name)) { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_STRING_OR_DATE, SecurityTypeDataModel.DataColumns.Name, data.Name); } else { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, SecurityTypeDataModel.DataColumns.Name); } break; case SecurityTypeDataModel.DataColumns.Description: if (!string.IsNullOrEmpty(data.Description)) { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_STRING_OR_DATE, SecurityTypeDataModel.DataColumns.Description, data.Description); } else { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, SecurityTypeDataModel.DataColumns.Description); } break; case SecurityTypeDataModel.DataColumns.SortOrder: if (data.SortOrder != null) { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NUMBER, SecurityTypeDataModel.DataColumns.SortOrder, data.SortOrder); } else { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, SecurityTypeDataModel.DataColumns.SortOrder); } break; default: returnValue = BaseDataManager.ToSQLParameter(data, dataColumnName); break; } return(returnValue); }
public SecurityTypeDataModel GetById(string value) { var dataQuery = new SecurityTypeDataModel(); dataQuery.SecurityTypeId = int.Parse(value); var result = SecurityTypeDataManager.GetEntityDetails(dataQuery, SessionVariables.RequestProfile, 1); return(result[0]); }
public static bool DoesExist(SecurityTypeDataModel data, RequestProfile requestProfile) { var doesExistRequest = new SecurityTypeDataModel(); doesExistRequest.ApplicationId = data.ApplicationId; doesExistRequest.Name = data.Name; var list = GetEntityDetails(doesExistRequest, requestProfile, 0); return(list.Count > 0); }
public static void Delete(SecurityTypeDataModel data, RequestProfile requestProfile) { const string sql = @"dbo.SecurityTypeDelete "; var parameters = new { AuditId = requestProfile.AuditId , SecurityTypeId = data.SecurityTypeId }; using (var dataAccess = new DataAccessBase(DataStoreKey)) { dataAccess.Connection.Execute(sql, parameters, commandType: CommandType.StoredProcedure); } }
public static List <SecurityTypeDataModel> GetEntityDetails(SecurityTypeDataModel dataQuery, RequestProfile requestProfile, int returnAuditInfo = BaseDataManager.ReturnAuditInfoOnDetails) { const string sql = @"dbo.SecurityTypeSearch "; var parameters = new { AuditId = requestProfile.AuditId , ApplicationId = requestProfile.ApplicationId , ReturnAuditInfo = returnAuditInfo , SecurityTypeId = dataQuery.SecurityTypeId , Name = dataQuery.Name }; List <SecurityTypeDataModel> result; using (var dataAccess = new DataAccessBase(DataStoreKey)) { result = dataAccess.Connection.Query <SecurityTypeDataModel>(sql, parameters, commandType: CommandType.StoredProcedure).ToList(); } return(result); }
public static void Update(SecurityTypeDataModel data, RequestProfile requestProfile) { var sql = Save(data, "Update", requestProfile); DBDML.RunSQL("SecurityType.Update", sql, DataStoreKey); }
public static DataTable Search(SecurityTypeDataModel data, RequestProfile requestProfile) { var list = GetEntityDetails(data, requestProfile, 0); return(list.ToDataTable()); }