public async Task Add(CommandContext context, [Description(Descriptions.WowCharacter)] UserWowCharacter character, [Description(Descriptions.WowProfession)] WowProfession profession, [Description(Descriptions.WowItemRecipe)][RemainingText] WowItemRecipe recipe) { var characterProfession = character.Character.WowCharacterProfessions .FirstOrDefault(x => x.WowProfessionId == profession.Id); if (characterProfession == null) { ResponseString = $"{character.Character} does not know {profession}"; return; } var charRecipe = character.Character.WowCharacterProfessions .FirstOrDefault(x => x.WowProfessionId == profession.Id) ?.WowCharacterRecipes .FirstOrDefault(x => x.RecipeId == recipe.Recipe.Id); if (charRecipe != null) { return; } charRecipe = new WowCharacterRecipe() { WowCharacterProfession = characterProfession, Recipe = recipe.Recipe, }; m_dbContext.WowCharacterRecipes.Add(charRecipe); await m_dbContext.SaveChangesAsync(); }
public Task List(CommandContext context, [Description(Descriptions.WowItemRecipe)][RemainingText] WowItemRecipe recipe) { var characters = Guild.WowServer.WowCharacters .Where(x => x.WowCharacterProfessions .Any(x => x.WowCharacterRecipes .Any(x => x.RecipeId == recipe.Recipe.Id))); StringBuilder message = new StringBuilder($"__**{recipe.Recipe}**__\n"); foreach (var character in characters) { message.AppendLine($"{character}"); } ResponseString = message.ToString(); return(Task.CompletedTask); }
public async Task Remove(CommandContext context, [Description(Descriptions.WowCharacter)] UserWowCharacter character, [Description(Descriptions.WowProfession)] WowProfession profession, [Description(Descriptions.WowItemRecipe)][RemainingText] WowItemRecipe recipe) { var charRecipe = character.Character.WowCharacterProfessions .FirstOrDefault(x => x.WowProfessionId == profession.Id) ?.WowCharacterRecipes .FirstOrDefault(x => x.RecipeId == recipe.Recipe.Id); if (charRecipe != null) { m_dbContext.WowCharacterRecipes.Remove(charRecipe); await m_dbContext.SaveChangesAsync(); } else { ResponseString = "Recipe not found"; return; } }