/// <summary>
        /// Updates the database with the character model given.
        /// Will not update Null fields
        /// </summary>
        /// <param name="character"></param>
        /// <returns></returns>
        public async Task UpdateCharacter(WoWCharacter character)
        {
            var dbCharacter = GetCharacter(character.character_id);

            if (dbCharacter != null)
            {
                try
                {
                    var apiCharacter = await warcraftClient.GetCharacterProfileSummaryAsync(character.realm.ToLower(), character.name.ToLower(), nameSpace);

                    if (apiCharacter.Success)
                    {
                        dbCharacter._class         = apiCharacter.Value.CharacterClass?.Name;
                        dbCharacter.level          = apiCharacter.Value.Level;
                        dbCharacter.guild          = apiCharacter.Value.Guild?.Name;
                        dbCharacter.armory         = ConvertToArmoryURL(character);
                        dbCharacter.role           = WoWUtilities.CheckRole(character.role, character._class);
                        dbCharacter.averageIlevel  = apiCharacter.Value.AverageItemLevel;
                        dbCharacter.equippedIlevel = apiCharacter.Value.EquippedItemLevel;
                        dbCharacter = await UpdateEquipment(dbCharacter);

                        context.SaveChanges();
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }
        }
Ejemplo n.º 2
0
        public Task AdminUpdateUser(User user)
        {
            var local = FindOrAddUser(user.DiscordID);

            if (user.Class != "TBC")
            {
                user.Role = WoWUtilities.CheckRole(user.Role, user.Class);
            }

            Utils.CopyProperties(local, user);

            context.SaveChanges();
            return(Task.CompletedTask);
        }
Ejemplo n.º 3
0
        public async Task UpdateUser(User user)
        {
            string[] propList = new string[] { "Nickname", "BisList", "Class", "Role", "About", "Experience", "AppLogs", "Armory", "BattleNet", "Days" };
            var      local    = FindOrAddUser(user.DiscordID);

            if (user.Class != "TBC")
            {
                user.Role = WoWUtilities.CheckRole(user.Role, user.Class);
            }

            Utils.CopyProperties(local, user, propList);

            if (user.AppStatus == "Sent" || user.AppStatus == "Not Sent")
            {
                local.AppStatus = user.AppStatus;

                if (user.AppStatus == "Sent")
                {
                    await ladBot.NewApplication(local);
                }
            }

            await context.SaveChangesAsync();
        }