public async Task CreateTopic(Topic topic, bool dryRun) { var existingTopics = await _topicRepository.GetAllAsync(); var existingClusters = await _clusterRepository.GetAllAsync(); if (existingTopics.Any(t => { return(t.Name.Equals(topic.Name) && t.KafkaClusterId.Equals(topic.KafkaClusterId)); })) { throw new TopicAlreadyExistException(topic.Name); } if (!existingClusters.Any(c => c.Id.Equals(topic.KafkaClusterId))) { throw new ClusterDoesNotExistException(topic.KafkaClusterId.ToString()); } if (!existingClusters.First(c => c.Id.Equals(topic.KafkaClusterId)).Enabled) { throw new ClusterIsDisabledException(); } if (dryRun) { return; } await _topicRepository.AddAsync(topic); }
public async Task <Cluster> GetNearestClusterAsync(double[] prediction) { var clusters = await _clusterRepository.GetAllAsync(); var nearest = await GetNearestClusterCoreAsync(prediction, clusters); var nearestWithPhotos = await _clusterRepository.GetWithPhotosAsync(nearest.Id); return(nearestWithPhotos); }
public async Task <IActionResult> GetAll() { var clusters = await _clusterRepository.GetAllAsync(); return(Ok(clusters)); }