public async Task<QueryResult> UpdateCharacter(string character, Character model)
 {
     if (string.IsNullOrEmpty(character))
         return QueryResult.EmptyField(nameof(character));
     if (model == null)
         return QueryResult.EmptyField(nameof(model));
     if (!model.Validate())
         return QueryResult.InvalidField(nameof(model));
     return QueryResult.QueryFailed(await _characterManager.UpdateCharacterAsync(model));
 }
 public async Task<bool> AddCharacterAsync(Character character)
 {
     if (!character.Validate() || Context.Characters.Any(c => c.Logograph == character.Logograph))
         return false;
     if (character.Priority <= 3)
         character.ReviewTime = DateTime.Now + TimeSpan.FromDays(4 - character.Priority);
     if (character.Priority > 3 && character.Priority <= 5)
         character.ReviewTime = DateTime.Now + TimeSpan.FromHours(6 - character.Priority);
     if (character.Priority > 5)
         character.ReviewTime = DateTime.Now + TimeSpan.FromMinutes(11 - character.Priority);
     Context.Characters.Add(character);
     await Save();
     return true;
 }
 public async Task<QueryResult> AddCharacter(Character character)
 {
     if (character == null)
         return QueryResult.EmptyField(nameof(character));
     if (!character.Validate())
         return QueryResult.InvalidField(nameof(character));
     if (character.Phrases == null)
         character.Phrases = new List<Phrase>();
     if (character.Idioms == null)
         character.Idioms = new List<Idiom>();
     if (!character.Usages.Any())
         return QueryResult.InvalidField(nameof(character));
     if (!await _characterManager.AddCharacterAsync(character))
         return QueryResult.QueryFailed("The character already exists");
     return QueryResult.Succeded;
 }
 public async Task<bool> UpdateCharacterAsync(Character character)
 {
     if (character == null || !character.Validate())
         return false;
     var original = await FindCharacterAsync(character.Logograph);
     if (original == null)
         return false;
     character.Number = original.Number;
     Context.Characters.Attach(character);
     Context.Entry(character).State = EntityState.Modified;
     await Save();
     return true;
 }