public void Update(TopicInput entity) { this.DbHelper.Execute(this.Table, proc => proc.AsUpdate(entity, "TypeId", "Title", "Content", "Modifier", "ModifyTime") .Where("Id", entity.Id) ); }
public void UpdateLikes(TopicInput entity) { object value = Expressions.UnsafeLiteral($"Likes + {entity.Likes}"); this.DbHelper.Execute(this.Table, proc => proc.AsUpdate(new[] { "Likes" }, new[] { value }) .Where("Id", entity.Id) ); }
public void Delete(TopicInput entity) { entity.IsDeleted = 1; this.DbHelper.Execute(this.Table, proc => proc.AsUpdate(entity, "IsDeleted", "Modifier", "ModifyTime") .Where("Id", entity.Id) ); }
public async Task <IActionResult> GetSubTopics([FromBody] TopicInput topicInput) { var topics = await topicsResourcesBusinessLogic.GetSubTopicsAsync(topicInput); if (topics == null) { return(StatusCode(StatusCodes.Status500InternalServerError)); } return(Ok(topics)); }
public async Task <dynamic> GetResourceAsync(TopicInput topicInput) { if (topicInput.IsShared) { return(await dbClient.FindItemsWhereArrayContainsAsync(dbSettings.ResourcesCollectionId, Constants.TopicTags, Constants.Id, topicInput.Id)); } else { return(await dbClient.FindItemsWhereArrayContainsAsyncWithLocation(dbSettings.ResourcesCollectionId, Constants.TopicTags, Constants.Id, topicInput.Id, topicInput.Location)); } }
public async Task <dynamic> GetDocumentAsync(TopicInput topicInput) { if (topicInput.IsShared) { return(await dbClient.FindItemsWhereAsync(dbSettings.TopicsCollectionId, Constants.Id, topicInput.Id)); } else { return(await dbClient.FindItemsWhereWithLocationAsync(dbSettings.TopicsCollectionId, Constants.Id, topicInput.Id, topicInput.Location)); } }
public async Task <IActionResult> GetResources([FromQuery] string state, [FromQuery] string topicName) { var topic = await topicsResourcesBusinessLogic.GetTopic(topicName); TopicInput topicInput = new TopicInput(); topicInput.Id = topic.Id; topicInput.Location = new Location() { State = state }; var resource = await topicsResourcesBusinessLogic.GetResourceAsync(topicInput); if (resource == null) { return(StatusCode(StatusCodes.Status404NotFound)); } return(Ok(resource)); }
public async Task <IActionResult> AddTopicToCapability(string id, [FromBody] TopicInput input) { var capabilityId = Guid.Empty; Guid.TryParse(id, out capabilityId); if (capabilityId == Guid.Empty) { return(BadRequest(new { Message = $"the capability id: {id} is malformed" })); } var capability = await _capabilityRepository.Get(capabilityId); IActionResult actionResult; try { var configurations = new Dictionary <string, object>(); if (input.Configurations != null) { foreach (var(key, value) in input.Configurations) { var jsonElement = (JsonElement)value; configurations[key] = JsonObjectTools.GetValueFromJsonElement(jsonElement); } } if (String.IsNullOrEmpty(input.KafkaClusterId)) { throw new ClusterNotSelectedException(); } var topic = Topic.Create( capabilityId, Guid.Parse(input.KafkaClusterId), capability.RootId, input.Name, input.Description, input.Partitions, input.Availability, configurations ); await _topicDomainService.CreateTopic( topic : topic, dryRun : true ); var kafkaCluster = await _topicDomainService.GetClusterById(topic.KafkaClusterId); if (input.DryRun) { return(Ok(DTOs.Topic.CreateFrom(topic))); } TaskFactoryExtensions.StartActionWithConsoleExceptions(async() => { await _kafkaJanitorRestClient.CreateTopic(topic, capability, kafkaCluster.ClusterId); await _topicDomainService.CreateTopic( topic: topic, dryRun: input.DryRun ); }); var topicDto = DTOs.Topic.CreateFrom(topic); actionResult = Ok(topicDto); } catch (Exception exception) when(ExceptionToStatusCode.CanConvert(exception, out actionResult)) { } return(actionResult); }
public void Insert(TopicInput entity) { this.DbHelper.Execute(this.Table, proc => proc.AsInsert(entity, "Id", "Creator", "CreateTime", "IsDeleted", "TypeId", "Title", "Content", "Likes", "Comments") ); }