using FHT.Core.Agency.Interfaces; using IO.Swagger.Api; using System.Threading.Tasks; namespace FHT.Agency.Web.CommandServices { public class TopicTypeService : ITopicTypeService { private readonly TopicTypeApiApi _topicTypeApi; public TopicTypeService(TopicTypeApiApi topicTypeApi) { _topicTypeApi = topicTypeApi; string token = new AuthorizationService().Login(); // _topicTypeApi.Configuration.AddDefaultHeader("Content-Type", "application/json"); _topicTypeApi.Configuration.AddDefaultHeader("Authorization", string.Format("bearer {0}", token)); } public async Task CreateOrUpdateAsync(int? topicTypeId, string title, string englishTitle, string pinyin, string description, string publishIconUrl, string webIconUrl, string businessOpportunityIconUrl, int order, bool isActive) { if (topicTypeId.HasValue) { await _topicTypeApi.TopicTypeApiChangeTopicTypeAsync(topicTypeId.Value, title, englishTitle, pinyin, description, publishIconUrl, webIconUrl, businessOpportunityIconUrl, order, isActive); } else { await _topicTypeApi.TopicTypeApiCreateTopicTypeAsync(title, englishTitle, pinyin,description, publishIconUrl, webIconUrl, businessOpportunityIconUrl,order,true); } } public async Task ChangeActiveStatusAsync(int topicTypeId, bool isActive) { if (isActive) { await _topicTypeApi.TopicTypeApiEnabledAsync(topicTypeId); } else { await _topicTypeApi.TopicTypeApiDisabledAsync(topicTypeId); } } } }