/// <summary> /// Initializes a new instance of the <see cref="ViewDataHelper"/> class. /// </summary> /// <param name="db"> /// The db. /// </param> public ViewDataHelper(LibiadaWebEntities db) { this.db = db; matterRepository = new MatterRepository(db); notationRepository = new NotationRepository(db); featureRepository = new FeatureRepository(db); characteristicTypeLinkRepository = new CharacteristicTypeLinkRepository(db); remoteDbRepository = new RemoteDbRepository(db); }
/// <summary> /// Extracts sequences from database. /// </summary> /// <param name="matterIds"> /// The matter ids. /// </param> /// <param name="notationIds"> /// The notation ids. /// </param> /// <param name="languageIds"> /// The language ids. /// </param> /// <param name="translatorIds"> /// The translator ids. /// </param> /// <returns> /// The <see cref="T:Chain[][]"/>. /// </returns> public Chain[][] GetChains(long[] matterIds, int[] notationIds, int[] languageIds, int?[] translatorIds) { var chains = new Chain[matterIds.Length][]; var notationsRepository = new NotationRepository(Db); for (int i = 0; i < matterIds.Length; i++) { var matterId = matterIds[i]; chains[i] = new Chain[notationIds.Length]; for (int j = 0; j < notationIds.Length; j++) { Notation notation = notationsRepository.Notations.Single(n => n.Id == notationIds[j]); long sequenceId; if (notation.Nature == Nature.Literature) { int languageId = languageIds[j]; int? translatorId = translatorIds[j]; sequenceId = Db.LiteratureSequence.Single(l => l.MatterId == matterId && l.NotationId == notation.Id && l.LanguageId == languageId && ((translatorId == null && l.TranslatorId == null) || (translatorId == l.TranslatorId))).Id; } else { sequenceId = Db.CommonSequence.Single(c => c.MatterId == matterId && c.NotationId == notation.Id).Id; } chains[i][j] = ToLibiadaChain(sequenceId); } } return chains; }