public async Task<QueryResult> AddPhraseUsage(string phrase, Usage usage) { if (string.IsNullOrEmpty(phrase)) return QueryResult.EmptyField(nameof(phrase)); if (usage == null) return QueryResult.EmptyField(nameof(usage)); if (string.IsNullOrEmpty(usage.Sentence)) return QueryResult.InvalidField(nameof(usage)); return QueryResult.QueryFailed(await Manager.UpdateUsageAsync(phrase, usage)); }
public async Task<QueryResult> AddCharacterUsage(string character, Usage usage) { if (usage == null) return QueryResult.EmptyField(nameof(usage)); if (string.IsNullOrEmpty(character)) return QueryResult.EmptyField(nameof(character)); if (usage.Sentence == null) return QueryResult.InvalidField(nameof(usage)); return QueryResult.QueryFailed(await _characterManager.UpdateUsageAsync(character, usage)); }
public async Task<bool> UpdateUsageAsync(string phrase, Usage usage) { if (string.IsNullOrEmpty(phrase) || string.IsNullOrEmpty(usage.Sentence)) return false; var c = await FindPhraseAsync(phrase); if (c == null) return false; c.Usages.Add(usage); await Save(); return true; }
public async Task<bool> UpdateUsageAsync(string character, Usage usage) { if (string.IsNullOrEmpty(character) || string.IsNullOrEmpty(usage.Sentence)) return false; var c = await FindCharacterAsync(character); if (c == null) return false; c.Usages.Add(usage); await Save(); return true; }