Esempio n. 1
0
 public static Description Create(Phrase phrase)
 {
     return new Description(phrase.Word, phrase.Definitions, phrase.Usages)
     {
         Type = "Phrase"
     };
 }
 public async Task<QueryResult> AddPhrase(Phrase phrase)
 {
     if (phrase == null)
         return QueryResult.EmptyField(nameof(phrase));
     if (!phrase.Validate())
         return QueryResult.InvalidField(nameof(phrase));
     if (phrase.Usages == null)
         return QueryResult.InvalidField(nameof(phrase));
     if (phrase.Definitions == null)
         return QueryResult.InvalidField(nameof(phrase));
     if (await Manager.AddPhraseAsync(phrase))
         return QueryResult.Succeded;
     return QueryResult.QueryFailed("The field already exists.");
 }
 public async Task<bool> AddPhraseAsync(Phrase phrase)
 {
     if (!phrase.Validate() && !await Context.Phrases.ContainsAsync(phrase))
         return false;
     Context.Phrases.Add(phrase);
     foreach (char i in phrase.Word)
     {
         Character c = await Manager.FindCharacterAsync(i.ToString());
         phrase.Characters.Add(c);
         c.Phrases.Add(phrase);
     }
     await Save();
     return true;
 }