예제 #1
0
        public static async Task AddUser(string apiKey)
        {
            using (var db = new UserContextFactory().CreateDbContext()) {
                var user = await GetUser(apiKey);

                if (user == null)
                {
                    var account = await AccountAPI.Account(apiKey);

                    if (db.User.Any(x => x.AccountName.Equals(account.Name)))
                    {
                        var existingUser = db.User.FirstOrDefault(x => x.AccountName.Equals(account.Name));
                        db.Key.Add(new Key {
                            UserID = existingUser.ID, APIKey = apiKey
                        });
                    }
                    else
                    {
                        var addedUser = db.User.Add(new User {
                            AccountName = account.Name
                        });
                        await db.SaveChangesAsync();

                        db.Key.Add(new Key {
                            UserID = addedUser.Entity.ID, APIKey = apiKey
                        });
                    }
                    await db.SaveChangesAsync();
                }
            }
        }
예제 #2
0
        public static async Task <AccountInventory> GetAccountInventory(string apiKey)
        {
            var accountInv = new AccountInventory()
            {
                Account         = await AccountAPI.Account(apiKey),
                Characters      = await CharacterAPI.Characters(apiKey),
                Bank            = await AccountAPI.Bank(apiKey),
                SharedInventory = await AccountAPI.SharedInventory(apiKey),
                Materials       = await AccountAPI.MaterialStorage(apiKey),
                Wallet          = await AccountAPI.Wallet(apiKey)
            };
            await accountInv.SetGuildBank(apiKey);

            return(accountInv);
        }
예제 #3
0
        internal async Task Populate(string apiKey)
        {
            Wallet = await AccountAPI.Wallet(apiKey);

            var characterResult = await CharacterAPI.Characters(apiKey);

            Characters = GroupItems(CharacterItems(characterResult));

            var bankResult = await AccountAPI.Bank(apiKey);

            Bank = GroupItems(GetItems(bankResult.Cast <Equipment>().ToList()));

            var sharedResult = await AccountAPI.SharedInventory(apiKey);

            SharedInventory = GroupItems(GetItems(sharedResult.Cast <Equipment>().ToList()));

            MaterialStorage = GroupItems(GetItems(await AccountAPI.MaterialStorage(apiKey)));
            DeliveryBox     = GroupItems(GetItems(GetDeliveryBox(await CommerceAPI.DeliveryBox(apiKey))));
            GuildBank       = GroupItems(GetItems(await GetGuildInventory(await AccountAPI.Account(apiKey), apiKey)));
        }