protected override int ExecuteWorkImplementation() { var bibliographicFormat = m_externalRepositoryRepository.Load <BibliographicFormat>(m_data.BibliographicFormat.Id); var externalRepositoryType = m_externalRepositoryRepository.Load <ExternalRepositoryType>(m_data.ExternalRepositoryType.Id); var user = m_externalRepositoryRepository.Load <User>(m_userId); var externalRepository = new ExternalRepository { Name = m_data.Name, Description = m_data.Description, Url = m_data.Url, Configuration = m_data.Configuration, UrlTemplate = m_data.UrlTemplate, License = m_data.License, BibliographicFormat = bibliographicFormat, ExternalRepositoryType = externalRepositoryType, CreatedByUser = user, FilteringExpressionSets = new List <FilteringExpressionSet>() }; if (m_data.FilteringExpressionSets != null) { foreach (var filteringExpressionSet in m_data.FilteringExpressionSets) { externalRepository.FilteringExpressionSets.Add( m_externalRepositoryRepository.Load <FilteringExpressionSet>(filteringExpressionSet.Id)); } } var resultId = (int)m_externalRepositoryRepository.Create(externalRepository); return(resultId); }
protected override void ExecuteWorkImplementation() { var externalRepository = m_externalRepositoryRepository.FindById <ExternalRepository>(m_externalRepositoryId); if (externalRepository == null) { throw new MainServiceException(MainServiceErrorCode.EntityNotFound, "The entity was not found."); } var bibliographicFormat = m_externalRepositoryRepository.Load <BibliographicFormat>(m_data.BibliographicFormat.Id); var externalRepositoryType = m_externalRepositoryRepository.Load <ExternalRepositoryType>(m_data.ExternalRepositoryType.Id); externalRepository.Name = m_data.Name; externalRepository.Description = m_data.Description; externalRepository.Url = m_data.Url; externalRepository.UrlTemplate = m_data.UrlTemplate; externalRepository.Configuration = m_data.Configuration; externalRepository.License = m_data.License; externalRepository.BibliographicFormat = bibliographicFormat; externalRepository.ExternalRepositoryType = externalRepositoryType; externalRepository.FilteringExpressionSets.Clear(); foreach (var filteringExpressionSet in m_data.FilteringExpressionSets) { externalRepository.FilteringExpressionSets.Add(m_externalRepositoryRepository.Load <FilteringExpressionSet>(filteringExpressionSet.Id)); } m_externalRepositoryRepository.Update(externalRepository); }
protected override void ExecuteWorkImplementation() { var externalRepository = m_externalRepositoryRepository.Load <ExternalRepository>(m_externalRepositoryId); if (externalRepository == null) { throw new MainServiceException(MainServiceErrorCode.EntityNotFound, "The entity was not found."); } if (externalRepository.ImportHistories == null || externalRepository.ImportHistories.Count > 0) { throw new MainServiceException(MainServiceErrorCode.RepositoryContainsHistory, "The external repository cannot be deleted, because it contains history.", HttpStatusCode.BadRequest); } m_externalRepositoryRepository.Delete(externalRepository); }