Esempio n. 1
0
            public async Task Remove(CommandContext context,
                                     [Description(Descriptions.WowCharacter)] UserWowCharacter character,
                                     [Description(Descriptions.WowProfession)] WowProfession profession,
                                     [Description("Confirm that you would like to remove this profession and all associated recipes.")] bool removeAllRecipes)
            {
                if (!removeAllRecipes)
                {
                    ResponseString = "You must pass 'true' for removeAllRecipes to confirm.";
                    return;
                }

                var charProfession = character.Character.WowCharacterProfessions
                                     .FirstOrDefault(x => x.WowProfessionId == profession.Id);

                if (charProfession != null)
                {
                    var recipes = character.Character.WowCharacterProfessions
                                  .Where(x => x.WowProfessionId == profession.Id)
                                  .SelectMany(x => x.WowCharacterRecipes);

                    m_dbContext.WowCharacterRecipes.RemoveRange(recipes);
                    m_dbContext.WowCharacterProfessions.Remove(charProfession);
                    await m_dbContext.SaveChangesAsync();
                }
            }
Esempio n. 2
0
 public async Task SetClass(CommandContext context,
                            [Description(Descriptions.WowCharacter)] UserWowCharacter character,
                            [Description(Descriptions.WowClass)] WowClass wowClass)
 {
     character.Character.WowClassId = wowClass.Id;
     await m_dbContext.SaveChangesAsync();
 }
Esempio n. 3
0
            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();
            }
Esempio n. 4
0
 public async Task SetFaction(CommandContext context,
                              [Description(Descriptions.WowCharacter)] UserWowCharacter character,
                              [Description(Descriptions.WowFaction)] WowFaction faction)
 {
     character.Character.WowFaction = faction;
     await m_dbContext.SaveChangesAsync();
 }
Esempio n. 5
0
 public async Task SetServer(CommandContext context,
                             [Description(Descriptions.WowCharacter)] UserWowCharacter character,
                             [Description(Descriptions.WowServer)] WowServer server)
 {
     character.Character.WowServerId = server.Id;
     await m_dbContext.SaveChangesAsync();
 }
Esempio n. 6
0
            public async Task Add(CommandContext context,
                                  [Description(Descriptions.WowCharacter)] UserWowCharacter character,
                                  [Description(Descriptions.WowProfession)] WowProfession profession)
            {
                if (character.Character.WowCharacterProfessions.Any(x => x.WowProfessionId == profession.Id))
                {
                    return;
                }

                m_dbContext.WowCharacterProfessions.Add(new WowCharacterProfession()
                {
                    WowCharacterId  = character.Character.Id,
                    WowProfessionId = profession.Id,
                });

                await m_dbContext.SaveChangesAsync();
            }
Esempio n. 7
0
            public async Task List(CommandContext context,
                                   [Description(Descriptions.WowCharacter)] UserWowCharacter character)
            {
                StringBuilder message = new StringBuilder();

                message.Append($"{character.Character}\n");
                foreach (var profession in character.Character.WowCharacterProfessions)
                {
                    message.Append($"\t{profession.WowProfession}\n");
                    foreach (var recipe in profession.WowCharacterRecipes)
                    {
                        message.Append($"\t\t{recipe.Recipe}\n");
                    }
                }

                var dmChannel = await context.Member.CreateDmChannelAsync();

                await dmChannel.SendMessageAsync(message.ToString());
            }
Esempio n. 8
0
            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;
                }
            }
Esempio n. 9
0
 public async Task RemoveCharacter(CommandContext context,
                                   [Description(Descriptions.WowCharacter)] UserWowCharacter character)
 {
     m_dbContext.WowCharacters.Remove(character.Character);
     await m_dbContext.SaveChangesAsync();
 }