| | | 1 | | namespace Chronicis.Client.Services; |
| | | 2 | | |
| | | 3 | | /// <inheritdoc cref="IWikiLinkCommitService"/> |
| | | 4 | | public class WikiLinkCommitService : IWikiLinkCommitService |
| | | 5 | | { |
| | | 6 | | private readonly IWikiLinkService _wikiLinkService; |
| | | 7 | | |
| | | 8 | | public WikiLinkCommitService(IWikiLinkService wikiLinkService) |
| | | 9 | | { |
| | 6 | 10 | | _wikiLinkService = wikiLinkService; |
| | 6 | 11 | | } |
| | | 12 | | |
| | | 13 | | /// <inheritdoc/> |
| | | 14 | | public AutocompleteCommitDecision Decide( |
| | | 15 | | string query, |
| | | 16 | | int suggestionsCount, |
| | | 17 | | int selectedIndex, |
| | | 18 | | bool isExternalQuery, |
| | | 19 | | bool isMapQuery) |
| | 3 | 20 | | => AutocompleteCommitDecision.Decide(query, suggestionsCount, selectedIndex, isExternalQuery, isMapQuery); |
| | | 21 | | |
| | | 22 | | /// <inheritdoc/> |
| | | 23 | | public async Task<WikiLinkCreateResult> CreateAndLinkAsync(string name, Guid worldId) |
| | | 24 | | { |
| | | 25 | | try |
| | | 26 | | { |
| | | 27 | | var article = await _wikiLinkService.CreateArticleFromAutocompleteAsync(name, worldId); |
| | | 28 | | if (article == null) |
| | | 29 | | return new WikiLinkCreateResult(false, null, "Failed to create article"); |
| | | 30 | | |
| | | 31 | | return new WikiLinkCreateResult(true, article, null); |
| | | 32 | | } |
| | | 33 | | catch (Exception ex) |
| | | 34 | | { |
| | | 35 | | return new WikiLinkCreateResult(false, null, ex.Message); |
| | | 36 | | } |
| | | 37 | | } |
| | | 38 | | } |