public bool CreateGroupingAndMetaData(int selectedProfileId, int selectedDomain, int nextIndicatorId, int selectedAreaType, int selectedSex, int selectedAgeRange, int selectedComparator, int selectedComparatorMethods, double selectedComparatorConfidences, int selectedYearType, int selectedYearRange, int selectedValueType, int selectedCiMethodType, double selectedCiConfidenceLevel, int selectedPolarityType, int selectedUnitType, int selectedDenominatorType, int startYear, int endYear, int startQuarterRange, int endQuarterRange, int startMonthRange, int endMonthRange, int? selectedDecimalPlaces, int? selectedTargetId) { var indicatorMetaData = new IndicatorMetadata() { IndicatorId = nextIndicatorId, DenominatorTypeId = selectedDenominatorType, CIMethodId = selectedCiMethodType, ValueTypeId = selectedValueType, UnitId = selectedUnitType, YearTypeId = selectedYearType, ConfidenceLevel = selectedCiConfidenceLevel, OwnerProfileId = selectedProfileId, DecimalPlacesDisplayed = selectedDecimalPlaces, TargetId = selectedTargetId, DateEntered = DateTime.Now }; try { transaction = CurrentSession.BeginTransaction(); CurrentSession.Save(indicatorMetaData); var nextAvailableIndicatorSequenceNumber = GetNextAvailableIndicatorSequenceNumber(selectedDomain); foreach (var comparatorId in GetComparatorIds(selectedComparator)) { InsertGrouping(selectedDomain, nextIndicatorId, selectedAreaType, selectedSex, selectedAgeRange, selectedComparatorMethods, selectedComparatorConfidences, selectedYearRange, selectedPolarityType, startYear, endYear, startQuarterRange, endQuarterRange, comparatorId, startMonthRange, endMonthRange, nextAvailableIndicatorSequenceNumber); } transaction.Commit(); return true; } catch (Exception exception) { HandleException(exception); } return false; }
public void DeleteIndicatorMetatdataById(IndicatorMetadata indicatorMetadata) { if (indicatorMetadata == null) { return; } ITransaction transaction = null; try { transaction = CurrentSession.BeginTransaction(); // Delete indicator metadata CurrentSession.Delete(indicatorMetadata); // Delete core data var queryString = "delete from CoreDataSet d where d.IndicatorId = :indicatorId"; IQuery q = CurrentSession.CreateQuery(queryString); q.SetParameter("indicatorId", indicatorMetadata.IndicatorId); q.ExecuteUpdate(); // Delete text values var sqlQuery = CurrentSession.CreateSQLQuery( "delete from IndicatorMetadataTextValues where indicatorid = " + indicatorMetadata.IndicatorId); sqlQuery.ExecuteUpdate(); transaction.Commit(); } catch (Exception) { if (transaction != null && transaction.WasRolledBack == false) { transaction.Rollback(); } throw; } }